package com.naze32.configurator;

import anywheresoftware.b4a.B4AMenuItem;
import android.app.Activity;
import android.os.Bundle;
import anywheresoftware.b4a.BA;
import anywheresoftware.b4a.BALayout;
import anywheresoftware.b4a.B4AActivity;
import anywheresoftware.b4a.ObjectWrapper;
import anywheresoftware.b4a.objects.ActivityWrapper;
import java.lang.reflect.InvocationTargetException;
import anywheresoftware.b4a.B4AUncaughtException;
import anywheresoftware.b4a.debug.*;
import java.lang.ref.WeakReference;

public class oscilo extends Activity implements B4AActivity{
	static oscilo mostCurrent;
	static boolean afterFirstLayout;
	static boolean isFirst = true;
    private static boolean processGlobalsRun = false;
	BALayout layout;
	public static BA processBA;
	BA activityBA;
    ActivityWrapper _activity;
    java.util.ArrayList<B4AMenuItem> menuItems;
	private static final boolean fullScreen = false;
	private static final boolean includeTitle = true;
    public static WeakReference<Activity> previousOne;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		if (isFirst) {
			processBA = new BA(this.getApplicationContext(), null, null, "com.naze32.configurator", "oscilo");
			processBA.loadHtSubs(this.getClass());
	        float deviceScale = getApplicationContext().getResources().getDisplayMetrics().density;
	        BALayout.setDeviceScale(deviceScale);
		}
		else if (previousOne != null) {
			Activity p = previousOne.get();
			if (p != null && p != this) {
                anywheresoftware.b4a.keywords.Common.Log("Killing previous instance (oscilo).");
				p.finish();
			}
		}
		if (!includeTitle) {
        	this.getWindow().requestFeature(android.view.Window.FEATURE_NO_TITLE);
        }
        if (fullScreen) {
        	getWindow().setFlags(android.view.WindowManager.LayoutParams.FLAG_FULLSCREEN,   
        			android.view.WindowManager.LayoutParams.FLAG_FULLSCREEN);
        }
		mostCurrent = this;
        processBA.activityBA = null;
		layout = new BALayout(this);
		setContentView(layout);
		afterFirstLayout = false;
		BA.handler.postDelayed(new WaitForLayout(), 5);

	}
	private static class WaitForLayout implements Runnable {
		public void run() {
			if (afterFirstLayout)
				return;
			if (mostCurrent.layout.getWidth() == 0) {
				BA.handler.postDelayed(this, 5);
				return;
			}
			mostCurrent.layout.getLayoutParams().height = mostCurrent.layout.getHeight();
			mostCurrent.layout.getLayoutParams().width = mostCurrent.layout.getWidth();
			afterFirstLayout = true;
			mostCurrent.afterFirstLayout();
		}
	}
	private void afterFirstLayout() {
		activityBA = new BA(this, layout, processBA, "com.naze32.configurator", "oscilo");
        processBA.activityBA = new java.lang.ref.WeakReference<BA>(activityBA);
        _activity = new ActivityWrapper(activityBA, "activity");
        anywheresoftware.b4a.Msgbox.isDismissing = false;
        initializeProcessGlobals();		
        initializeGlobals();
        anywheresoftware.b4a.objects.ViewWrapper.lastId = 0;
        anywheresoftware.b4a.keywords.Common.Log("** Activity (oscilo) Create, isFirst = " + isFirst + " **");
        processBA.raiseEvent2(null, true, "activity_create", false, isFirst);
		isFirst = false;
		if (mostCurrent == null || mostCurrent != this)
			return;
        processBA.setActivityPaused(false);
        anywheresoftware.b4a.keywords.Common.Log("** Activity (oscilo) Resume **");
        processBA.raiseEvent(null, "activity_resume");

	}
	public void addMenuItem(B4AMenuItem item) {
		if (menuItems == null)
			menuItems = new java.util.ArrayList<B4AMenuItem>();
		menuItems.add(item);
	}
	@Override
	public boolean onCreateOptionsMenu(android.view.Menu menu) {
		super.onCreateOptionsMenu(menu);
		if (menuItems == null)
			return false;
		for (B4AMenuItem bmi : menuItems) {
			android.view.MenuItem mi = menu.add(bmi.title);
			if (bmi.drawable != null)
				mi.setIcon(bmi.drawable);
			mi.setOnMenuItemClickListener(new B4AMenuItemsClickListener(bmi.eventName.toLowerCase(BA.cul)));
		}
		return true;
	}
	private class B4AMenuItemsClickListener implements android.view.MenuItem.OnMenuItemClickListener {
		private final String eventName;
		public B4AMenuItemsClickListener(String eventName) {
			this.eventName = eventName;
		}
		public boolean onMenuItemClick(android.view.MenuItem item) {
			processBA.raiseEvent(item.getTitle(), eventName + "_click");
			return true;
		}
	}
    public static Class<?> getObject() {
		return oscilo.class;
	}
    private Boolean onKeySubExist = null;
    private Boolean onKeyUpSubExist = null;
	@Override
	public boolean onKeyDown(int keyCode, android.view.KeyEvent event) {
		if (onKeySubExist == null)
			onKeySubExist = processBA.subExists("activity_keypress");
		if (onKeySubExist) {
			Boolean res =  (Boolean)processBA.raiseEvent2(_activity, false, "activity_keypress", false, keyCode);
			if (res == null || res == true)
				return true;
		}
		return super.onKeyDown(keyCode, event);
	}
    @Override
	public boolean onKeyUp(int keyCode, android.view.KeyEvent event) {
		if (onKeyUpSubExist == null)
			onKeyUpSubExist = processBA.subExists("activity_keyup");
		if (onKeyUpSubExist) {
			Boolean res =  (Boolean)processBA.raiseEvent2(_activity, false, "activity_keyup", false, keyCode);
			if (res == null || res == true)
				return true;
		}
		return super.onKeyUp(keyCode, event);
	}
	@Override
	public void onNewIntent(android.content.Intent intent) {
		this.setIntent(intent);
	}
    @Override 
	public void onPause() {
		super.onPause();
        if (_activity == null) //workaround for emulator bug (Issue 2423)
            return;
		anywheresoftware.b4a.Msgbox.dismiss(true);
        anywheresoftware.b4a.keywords.Common.Log("** Activity (oscilo) Pause, UserClosed = " + activityBA.activity.isFinishing() + " **");
        processBA.raiseEvent2(_activity, true, "activity_pause", false, activityBA.activity.isFinishing());		
        processBA.setActivityPaused(true);
        mostCurrent = null;
        if (!activityBA.activity.isFinishing())
			previousOne = new WeakReference<Activity>(this);
        anywheresoftware.b4a.Msgbox.isDismissing = false;
	}

	@Override
	public void onDestroy() {
        super.onDestroy();
		previousOne = null;
	}
    @Override 
	public void onResume() {
		super.onResume();
        mostCurrent = this;
        anywheresoftware.b4a.Msgbox.isDismissing = false;
        if (activityBA != null) { //will be null during activity create (which waits for AfterLayout).
        	ResumeMessage rm = new ResumeMessage(mostCurrent);
        	BA.handler.post(rm);
        }
	}
    private static class ResumeMessage implements Runnable {
    	private final WeakReference<Activity> activity;
    	public ResumeMessage(Activity activity) {
    		this.activity = new WeakReference<Activity>(activity);
    	}
		public void run() {
			if (mostCurrent == null || mostCurrent != activity.get())
				return;
			processBA.setActivityPaused(false);
            anywheresoftware.b4a.keywords.Common.Log("** Activity (oscilo) Resume **");
		    processBA.raiseEvent(mostCurrent._activity, "activity_resume", (Object[])null);
		}
    }
	@Override
	protected void onActivityResult(int requestCode, int resultCode,
	      android.content.Intent data) {
		processBA.onActivityResult(requestCode, resultCode, data);
	}
	private static void initializeGlobals() {
		processBA.raiseEvent2(null, true, "globals", false, (Object[])null);
	}

public static class _curves{
boolean IsInitialized;
String Name;
int Color;
float Width;
double Scale;
double offset;
boolean Draw;
public void Initialize() {
IsInitialized = true;
Name = "";
Color = 0;
Width = 0f;
Scale = 0;
offset = 0;
Draw = false;
}
@Override
		public String toString() {
			return BA.TypeToString(this);
		}}
public anywheresoftware.b4a.keywords.Common __c = null;
public static anywheresoftware.b4a.objects.Timer _timer1 = null;
public static double[][] _curveval = null;
public static int _screenx0 = 0;
public static int _screenx1 = 0;
public static int _screeny0 = 0;
public static int _screeny1 = 0;
public static int _screenw = 0;
public static int _screenh = 0;
public static int _border = 0;
public static int _gridx0 = 0;
public static int _gridx1 = 0;
public static int _gridy0 = 0;
public static int _gridy1 = 0;
public static int _gridym = 0;
public static int _gridw = 0;
public static int _gridh = 0;
public static int _div = 0;
public static int _nbdivx = 0;
public static int _nbdivy = 0;
public static int _screencol = 0;
public static int _gridlinecol = 0;
public static double _t = 0;
public static double _dt = 0;
public static float _dx = 0f;
public static float _xx = 0f;
public static float _cx = 0f;
public static int _ii = 0;
public static int _curvei = 0;
public static oscilo._curves[] _curve = null;
public static int[] _curvesi = null;
public static int _curvesnb = 0;
public static int _curvesnbdisp = 0;
public static float[] _y1 = null;
public static float[] _y2 = null;
public static boolean _singleshot = false;
public static boolean _stopped = false;
public static String _scopemode = "";
public static boolean _scoperolling = false;
public static double[] _w = null;
public static double[] _a = null;
public static double[] _timescale = null;
public static double[] _signalscale = null;
public static String _msp_ident = "";
public static String _msp_status = "";
public static String _msp_raw_imu = "";
public static String _msp_servo = "";
public static String _msp_motor = "";
public static String _msp_rc = "";
public static String _msp_raw_gps = "";
public static String _msp_comp_gps = "";
public static String _msp_attitude = "";
public static String _msp_altitude = "";
public static String _msp_bat = "";
public static String _msp_rc_tuning = "";
public static String _msp_pid = "";
public static String _msp_box = "";
public static String _msp_misc = "";
public static String _msp_set_raw_rc = "";
public static String _msp_set_raw_gps = "";
public static String _msp_set_pid = "";
public static String _msp_set_box = "";
public static String _msp_set_rc_tuning = "";
public static String _msp_acc_calibration = "";
public static String _msp_mag_calibration = "";
public static String _msp_set_misc = "";
public static String _msp_reset_conf = "";
public static String _msp_eeprom_write = "";
public static String _msp_debug = "";
public static int _statemsp = 0;
public static int _offset = 0;
public static int _datasize = 0;
public static int _indtx = 0;
public static byte _checksum = 0;
public anywheresoftware.b4a.objects.ButtonWrapper _btnstart = null;
public anywheresoftware.b4a.objects.ButtonWrapper _btnstop = null;
public anywheresoftware.b4a.objects.ButtonWrapper _btnsingleshot = null;
public anywheresoftware.b4a.objects.PanelWrapper _pnlocilloscope = null;
public anywheresoftware.b4a.objects.PanelWrapper _pnlscreen = null;
public anywheresoftware.b4a.objects.PanelWrapper _pnlgraph = null;
public anywheresoftware.b4a.objects.PanelWrapper _pnlcursor = null;
public anywheresoftware.b4a.objects.PanelWrapper _pnlcontrol = null;
public anywheresoftware.b4a.objects.PanelWrapper _pnlcurvetools = null;
public anywheresoftware.b4a.objects.PanelWrapper _pnldispvalues = null;
public anywheresoftware.b4a.objects.drawable.CanvasWrapper _cvsscreen = null;
public anywheresoftware.b4a.objects.drawable.CanvasWrapper _cvsgraph = null;
public anywheresoftware.b4a.objects.drawable.CanvasWrapper _cvscursor = null;
public anywheresoftware.b4a.objects.drawable.CanvasWrapper.RectWrapper _rectscreen = null;
public anywheresoftware.b4a.objects.drawable.CanvasWrapper.RectWrapper _rectgrid = null;
public anywheresoftware.b4a.objects.SpinnerWrapper _spntimescale = null;
public anywheresoftware.b4a.objects.SpinnerWrapper _spnscale0 = null;
public anywheresoftware.b4a.objects.SpinnerWrapper _spnscale1 = null;
public anywheresoftware.b4a.objects.SpinnerWrapper _spnscale2 = null;
public anywheresoftware.b4a.objects.SpinnerWrapper _spnscale3 = null;
public anywheresoftware.b4a.objects.LabelWrapper _lblscale0 = null;
public anywheresoftware.b4a.objects.LabelWrapper _lblscale1 = null;
public anywheresoftware.b4a.objects.LabelWrapper _lblscale2 = null;
public anywheresoftware.b4a.objects.LabelWrapper _lblscale3 = null;
public anywheresoftware.b4a.objects.LabelWrapper _lblvalue0 = null;
public anywheresoftware.b4a.objects.LabelWrapper _lblvalue1 = null;
public anywheresoftware.b4a.objects.LabelWrapper _lblvalue2 = null;
public anywheresoftware.b4a.objects.LabelWrapper _lblvalue3 = null;
public anywheresoftware.b4a.objects.LabelWrapper _lbloffset0 = null;
public anywheresoftware.b4a.objects.LabelWrapper _lbloffset1 = null;
public anywheresoftware.b4a.objects.LabelWrapper _lbloffset2 = null;
public anywheresoftware.b4a.objects.LabelWrapper _lbloffset3 = null;
public anywheresoftware.b4a.objects.EditTextWrapper _edtoffset0 = null;
public anywheresoftware.b4a.objects.EditTextWrapper _edtoffset1 = null;
public anywheresoftware.b4a.objects.EditTextWrapper _edtoffset2 = null;
public anywheresoftware.b4a.objects.EditTextWrapper _edtoffset3 = null;
public anywheresoftware.b4a.objects.CompoundButtonWrapper.RadioButtonWrapper _rbtscopescope = null;
public anywheresoftware.b4a.objects.CompoundButtonWrapper.RadioButtonWrapper _rbtscopemem = null;
public anywheresoftware.b4a.objects.CompoundButtonWrapper.RadioButtonWrapper _rbtscoperoll = null;
public anywheresoftware.b4a.objects.ScrollViewWrapper _scvcontrol = null;
public anywheresoftware.b4a.objects.drawable.CanvasWrapper.BitmapWrapper _bmproll = null;
public anywheresoftware.b4a.objects.collections.List _choselist = null;
public anywheresoftware.b4a.objects.LabelWrapper[] _labelcheckbox = null;
public static String[] _checkboxtags = null;
public anywheresoftware.b4a.objects.LabelWrapper[] _vals = null;
public static int _id = 0;
public main _main = null;
public cli _cli = null;
public slidingpanels _slidingpanels = null;
public static String  _activity_create(boolean _firsttime) throws Exception{
int _w1 = 0;
int _w2 = 0;
int _w3 = 0;
int _t1 = 0;
int _h1 = 0;
anywheresoftware.b4a.objects.drawable.ColorDrawable _cbg = null;
float _ww = 0f;
int _i = 0;
anywheresoftware.b4a.objects.CompoundButtonWrapper.CheckBoxWrapper _cbx = null;
 //BA.debugLineNum = 93;BA.debugLine="Sub Activity_Create(FirstTime As Boolean)";
 //BA.debugLineNum = 95;BA.debugLine="choselist.Initialize";
mostCurrent._choselist.Initialize();
 //BA.debugLineNum = 97;BA.debugLine="choselist.AddAll(Array As String (\"Ax\",\"Ay\",\"Az\",\"Gx\",\"Gy\",\"Gz\",\"Mag x\",\"Mag y\",\"Mag z\"))";
mostCurrent._choselist.AddAll(anywheresoftware.b4a.keywords.Common.ArrayToList(new String[]{"Ax","Ay","Az","Gx","Gy","Gz","Mag x","Mag y","Mag z"}));
 //BA.debugLineNum = 98;BA.debugLine="t = 0";
_t = 0;
 //BA.debugLineNum = 99;BA.debugLine="If Main.protocol=0 Then";
if (mostCurrent._main._protocol==0) { 
 //BA.debugLineNum = 100;BA.debugLine="Timer1.Initialize(\"Timer1\", 75)";
_timer1.Initialize(processBA,"Timer1",(long)(75));
 }else {
 //BA.debugLineNum = 102;BA.debugLine="Timer1.Initialize(\"Timer1\", 35)";
_timer1.Initialize(processBA,"Timer1",(long)(35));
 };
 //BA.debugLineNum = 104;BA.debugLine="NbDivX = 10";
_nbdivx = (int)(10);
 //BA.debugLineNum = 105;BA.debugLine="NbDivY = 8";
_nbdivy = (int)(8);
 //BA.debugLineNum = 107;BA.debugLine="Div = Floor(80%y / NbDivY)";
_div = (int)(anywheresoftware.b4a.keywords.Common.Floor(anywheresoftware.b4a.keywords.Common.PerYToCurrent((float)(80),mostCurrent.activityBA)/(double)_nbdivy));
 //BA.debugLineNum = 109;BA.debugLine="xx = 0";
_xx = (float)(0);
 //BA.debugLineNum = 110;BA.debugLine="dx = Div / 10";
_dx = (float)(_div/(double)10);
 //BA.debugLineNum = 111;BA.debugLine="GridW = Div * NbDivX";
_gridw = (int)(_div*_nbdivx);
 //BA.debugLineNum = 112;BA.debugLine="GridH = Div * NbDivY";
_gridh = (int)(_div*_nbdivy);
 //BA.debugLineNum = 113;BA.debugLine="Border = 6dip";
_border = anywheresoftware.b4a.keywords.Common.DipToCurrent((int)(6));
 //BA.debugLineNum = 115;BA.debugLine="ScreenY0 = 0";
_screeny0 = (int)(0);
 //BA.debugLineNum = 116;BA.debugLine="ScreenH = GridH + 2 * Border";
_screenh = (int)(_gridh+2*_border);
 //BA.debugLineNum = 117;BA.debugLine="ScreenY1 = ScreenY0 + ScreenH";
_screeny1 = (int)(_screeny0+_screenh);
 //BA.debugLineNum = 119;BA.debugLine="ScreenX0 = 0";
_screenx0 = (int)(0);
 //BA.debugLineNum = 120;BA.debugLine="ScreenW = GridW + 2 * Border";
_screenw = (int)(_gridw+2*_border);
 //BA.debugLineNum = 121;BA.debugLine="ScreenX1 = ScreenX0 + ScreenW";
_screenx1 = (int)(_screenx0+_screenw);
 //BA.debugLineNum = 123;BA.debugLine="GridY0 = Border";
_gridy0 = _border;
 //BA.debugLineNum = 124;BA.debugLine="GridY1 = GridY0 + GridH";
_gridy1 = (int)(_gridy0+_gridh);
 //BA.debugLineNum = 125;BA.debugLine="GridX0 = Border";
_gridx0 = _border;
 //BA.debugLineNum = 126;BA.debugLine="GridX1 = GridX0 + GridW";
_gridx1 = (int)(_gridx0+_gridw);
 //BA.debugLineNum = 127;BA.debugLine="GridYm = GridH / 2";
_gridym = (int)(_gridh/(double)2);
 //BA.debugLineNum = 129;BA.debugLine="rectGrid.Initialize(0, 0, GridW, GridH)";
mostCurrent._rectgrid.Initialize((int)(0),(int)(0),_gridw,_gridh);
 //BA.debugLineNum = 130;BA.debugLine="rectScreen.Initialize(0, 0, ScreenW, ScreenH)";
mostCurrent._rectscreen.Initialize((int)(0),(int)(0),_screenw,_screenh);
 //BA.debugLineNum = 132;BA.debugLine="ScreenCol = Colors.black";
_screencol = anywheresoftware.b4a.keywords.Common.Colors.Black;
 //BA.debugLineNum = 133;BA.debugLine="GridLineCol = Colors.Gray";
_gridlinecol = anywheresoftware.b4a.keywords.Common.Colors.Gray;
 //BA.debugLineNum = 135;BA.debugLine="pnlOcilloscope.Initialize(\"\")";
mostCurrent._pnlocilloscope.Initialize(mostCurrent.activityBA,"");
 //BA.debugLineNum = 136;BA.debugLine="Activity.AddView(pnlOcilloscope, 0, 0, 100%x, 100%y)";
mostCurrent._activity.AddView((android.view.View)(mostCurrent._pnlocilloscope.getObject()),(int)(0),(int)(0),anywheresoftware.b4a.keywords.Common.PerXToCurrent((float)(100),mostCurrent.activityBA),anywheresoftware.b4a.keywords.Common.PerYToCurrent((float)(100),mostCurrent.activityBA));
 //BA.debugLineNum = 138;BA.debugLine="pnlScreen.Initialize(\"\")";
mostCurrent._pnlscreen.Initialize(mostCurrent.activityBA,"");
 //BA.debugLineNum = 139;BA.debugLine="pnlOcilloscope.AddView(pnlScreen, ScreenX0, ScreenY0, ScreenW, ScreenH)";
mostCurrent._pnlocilloscope.AddView((android.view.View)(mostCurrent._pnlscreen.getObject()),_screenx0,_screeny0,_screenw,_screenh);
 //BA.debugLineNum = 140;BA.debugLine="cvsScreen.Initialize(pnlScreen)";
mostCurrent._cvsscreen.Initialize((android.view.View)(mostCurrent._pnlscreen.getObject()));
 //BA.debugLineNum = 142;BA.debugLine="pnlGraph.Initialize(\"\")";
mostCurrent._pnlgraph.Initialize(mostCurrent.activityBA,"");
 //BA.debugLineNum = 143;BA.debugLine="pnlOcilloscope.AddView(pnlGraph, GridX0, GridY0, GridW, GridH)";
mostCurrent._pnlocilloscope.AddView((android.view.View)(mostCurrent._pnlgraph.getObject()),_gridx0,_gridy0,_gridw,_gridh);
 //BA.debugLineNum = 144;BA.debugLine="cvsGraph.Initialize(pnlGraph)";
mostCurrent._cvsgraph.Initialize((android.view.View)(mostCurrent._pnlgraph.getObject()));
 //BA.debugLineNum = 146;BA.debugLine="pnlCursor.Initialize(\"pnlCursor\")";
mostCurrent._pnlcursor.Initialize(mostCurrent.activityBA,"pnlCursor");
 //BA.debugLineNum = 147;BA.debugLine="pnlOcilloscope.AddView(pnlCursor, GridX0, GridY0, GridW, GridH)";
mostCurrent._pnlocilloscope.AddView((android.view.View)(mostCurrent._pnlcursor.getObject()),_gridx0,_gridy0,_gridw,_gridh);
 //BA.debugLineNum = 148;BA.debugLine="cvsCursor.Initialize(pnlCursor)";
mostCurrent._cvscursor.Initialize((android.view.View)(mostCurrent._pnlcursor.getObject()));
 //BA.debugLineNum = 152;BA.debugLine="Dim w1, w2, w3, t1, h1 As Int";
_w1 = 0;
_w2 = 0;
_w3 = 0;
_t1 = 0;
_h1 = 0;
 //BA.debugLineNum = 153;BA.debugLine="w1 = 4dip";
_w1 = anywheresoftware.b4a.keywords.Common.DipToCurrent((int)(4));
 //BA.debugLineNum = 154;BA.debugLine="w2 = 0";
_w2 = (int)(0);
 //BA.debugLineNum = 155;BA.debugLine="w3 = w1 + w2";
_w3 = (int)(_w1+_w2);
 //BA.debugLineNum = 156;BA.debugLine="t1 = 4dip";
_t1 = anywheresoftware.b4a.keywords.Common.DipToCurrent((int)(4));
 //BA.debugLineNum = 157;BA.debugLine="h1 = 52dip";
_h1 = anywheresoftware.b4a.keywords.Common.DipToCurrent((int)(52));
 //BA.debugLineNum = 158;BA.debugLine="Activity.AddMenuItem(\"Start\",\"btnStart\")";
mostCurrent._activity.AddMenuItem("Start","btnStart");
 //BA.debugLineNum = 159;BA.debugLine="Activity.AddMenuItem(\"Stop\",\"btnStop\")";
mostCurrent._activity.AddMenuItem("Stop","btnStop");
 //BA.debugLineNum = 160;BA.debugLine="Activity.AddMenuItem(\"Single\",\"btnSingleShot\")";
mostCurrent._activity.AddMenuItem("Single","btnSingleShot");
 //BA.debugLineNum = 167;BA.debugLine="Dim cbg As ColorDrawable";
_cbg = new anywheresoftware.b4a.objects.drawable.ColorDrawable();
 //BA.debugLineNum = 168;BA.debugLine="cbg.Initialize(Colors.RGB(196, 196, 255), 0)";
_cbg.Initialize(anywheresoftware.b4a.keywords.Common.Colors.RGB((int)(196),(int)(196),(int)(255)),(int)(0));
 //BA.debugLineNum = 172;BA.debugLine="pnlCurveTools.Initialize(\"\")";
mostCurrent._pnlcurvetools.Initialize(mostCurrent.activityBA,"");
 //BA.debugLineNum = 173;BA.debugLine="pnlOcilloscope.AddView(pnlCurveTools, 0, ScreenY1, 100%x, 100%y - ScreenY1)";
mostCurrent._pnlocilloscope.AddView((android.view.View)(mostCurrent._pnlcurvetools.getObject()),(int)(0),_screeny1,anywheresoftware.b4a.keywords.Common.PerXToCurrent((float)(100),mostCurrent.activityBA),(int)(anywheresoftware.b4a.keywords.Common.PerYToCurrent((float)(100),mostCurrent.activityBA)-_screeny1));
 //BA.debugLineNum = 174;BA.debugLine="Dim cbg As ColorDrawable";
_cbg = new anywheresoftware.b4a.objects.drawable.ColorDrawable();
 //BA.debugLineNum = 175;BA.debugLine="cbg.Initialize(Colors.RGB(0, 0, 0), 0)";
_cbg.Initialize(anywheresoftware.b4a.keywords.Common.Colors.RGB((int)(0),(int)(0),(int)(0)),(int)(0));
 //BA.debugLineNum = 176;BA.debugLine="pnlCurveTools.Background = cbg";
mostCurrent._pnlcurvetools.setBackground((android.graphics.drawable.Drawable)(_cbg.getObject()));
 //BA.debugLineNum = 178;BA.debugLine="pnlDispValues.Initialize(\"\")";
mostCurrent._pnldispvalues.Initialize(mostCurrent.activityBA,"");
 //BA.debugLineNum = 179;BA.debugLine="pnlOcilloscope.AddView(pnlDispValues, 0, ScreenY1, 100%x, 100%y - ScreenY1)";
mostCurrent._pnlocilloscope.AddView((android.view.View)(mostCurrent._pnldispvalues.getObject()),(int)(0),_screeny1,anywheresoftware.b4a.keywords.Common.PerXToCurrent((float)(100),mostCurrent.activityBA),(int)(anywheresoftware.b4a.keywords.Common.PerYToCurrent((float)(100),mostCurrent.activityBA)-_screeny1));
 //BA.debugLineNum = 180;BA.debugLine="Dim cbg As ColorDrawable";
_cbg = new anywheresoftware.b4a.objects.drawable.ColorDrawable();
 //BA.debugLineNum = 181;BA.debugLine="cbg.Initialize(Colors.RGB(255, 236, 153), 0)";
_cbg.Initialize(anywheresoftware.b4a.keywords.Common.Colors.RGB((int)(255),(int)(236),(int)(153)),(int)(0));
 //BA.debugLineNum = 182;BA.debugLine="pnlDispValues.Background = cbg";
mostCurrent._pnldispvalues.setBackground((android.graphics.drawable.Drawable)(_cbg.getObject()));
 //BA.debugLineNum = 183;BA.debugLine="pnlDispValues.Visible = False";
mostCurrent._pnldispvalues.setVisible(anywheresoftware.b4a.keywords.Common.False);
 //BA.debugLineNum = 185;BA.debugLine="InitCurves";
_initcurves();
 //BA.debugLineNum = 186;BA.debugLine="InitCalcCurves";
_initcalccurves();
 //BA.debugLineNum = 187;BA.debugLine="InitSpinners";
_initspinners();
 //BA.debugLineNum = 189;BA.debugLine="Dim ww As Float";
_ww = 0f;
 //BA.debugLineNum = 190;BA.debugLine="ww = pnlDispValues.Width / 4";
_ww = (float)(mostCurrent._pnldispvalues.getWidth()/(double)4);
 //BA.debugLineNum = 191;BA.debugLine="lblValue0.Initialize(\"\")";
mostCurrent._lblvalue0.Initialize(mostCurrent.activityBA,"");
 //BA.debugLineNum = 192;BA.debugLine="pnlDispValues.AddView(lblValue0, 0, 0, ww, pnlDispValues.Height)";
mostCurrent._pnldispvalues.AddView((android.view.View)(mostCurrent._lblvalue0.getObject()),(int)(0),(int)(0),(int)(_ww),mostCurrent._pnldispvalues.getHeight());
 //BA.debugLineNum = 193;BA.debugLine="lblValue0.TextColor = Curve(0).Color";
mostCurrent._lblvalue0.setTextColor(_curve[(int)(0)].Color);
 //BA.debugLineNum = 194;BA.debugLine="lblValue0.Gravity = Gravity.CENTER_HORIZONTAL + Gravity.CENTER_VERTICAL";
mostCurrent._lblvalue0.setGravity((int)(anywheresoftware.b4a.keywords.Common.Gravity.CENTER_HORIZONTAL+anywheresoftware.b4a.keywords.Common.Gravity.CENTER_VERTICAL));
 //BA.debugLineNum = 196;BA.debugLine="lblValue1.Initialize(\"\")";
mostCurrent._lblvalue1.Initialize(mostCurrent.activityBA,"");
 //BA.debugLineNum = 197;BA.debugLine="pnlDispValues.AddView(lblValue1, ww, 0, ww, pnlDispValues.Height)";
mostCurrent._pnldispvalues.AddView((android.view.View)(mostCurrent._lblvalue1.getObject()),(int)(_ww),(int)(0),(int)(_ww),mostCurrent._pnldispvalues.getHeight());
 //BA.debugLineNum = 198;BA.debugLine="lblValue1.TextColor = Curve(1).Color";
mostCurrent._lblvalue1.setTextColor(_curve[(int)(1)].Color);
 //BA.debugLineNum = 199;BA.debugLine="lblValue1.Gravity = Gravity.CENTER_HORIZONTAL + Gravity.CENTER_VERTICAL";
mostCurrent._lblvalue1.setGravity((int)(anywheresoftware.b4a.keywords.Common.Gravity.CENTER_HORIZONTAL+anywheresoftware.b4a.keywords.Common.Gravity.CENTER_VERTICAL));
 //BA.debugLineNum = 201;BA.debugLine="lblValue2.Initialize(\"\")";
mostCurrent._lblvalue2.Initialize(mostCurrent.activityBA,"");
 //BA.debugLineNum = 202;BA.debugLine="pnlDispValues.AddView(lblValue2, 2 * ww, 0, ww, pnlDispValues.Height)";
mostCurrent._pnldispvalues.AddView((android.view.View)(mostCurrent._lblvalue2.getObject()),(int)(2*_ww),(int)(0),(int)(_ww),mostCurrent._pnldispvalues.getHeight());
 //BA.debugLineNum = 203;BA.debugLine="lblValue2.TextColor = Curve(2).Color";
mostCurrent._lblvalue2.setTextColor(_curve[(int)(2)].Color);
 //BA.debugLineNum = 204;BA.debugLine="lblValue2.Gravity = Gravity.CENTER_HORIZONTAL + Gravity.CENTER_VERTICAL";
mostCurrent._lblvalue2.setGravity((int)(anywheresoftware.b4a.keywords.Common.Gravity.CENTER_HORIZONTAL+anywheresoftware.b4a.keywords.Common.Gravity.CENTER_VERTICAL));
 //BA.debugLineNum = 206;BA.debugLine="lblValue3.Initialize(\"\")";
mostCurrent._lblvalue3.Initialize(mostCurrent.activityBA,"");
 //BA.debugLineNum = 207;BA.debugLine="pnlDispValues.AddView(lblValue3, 3 * ww, 0, ww, pnlDispValues.Height)";
mostCurrent._pnldispvalues.AddView((android.view.View)(mostCurrent._lblvalue3.getObject()),(int)(3*_ww),(int)(0),(int)(_ww),mostCurrent._pnldispvalues.getHeight());
 //BA.debugLineNum = 208;BA.debugLine="lblValue3.TextColor = Curve(3).Color";
mostCurrent._lblvalue3.setTextColor(_curve[(int)(3)].Color);
 //BA.debugLineNum = 209;BA.debugLine="lblValue3.Gravity = Gravity.CENTER_HORIZONTAL + Gravity.CENTER_VERTICAL";
mostCurrent._lblvalue3.setGravity((int)(anywheresoftware.b4a.keywords.Common.Gravity.CENTER_HORIZONTAL+anywheresoftware.b4a.keywords.Common.Gravity.CENTER_VERTICAL));
 //BA.debugLineNum = 212;BA.debugLine="For i = 0 To 3";
{
final double step173 = 1;
final double limit173 = (int)(3);
for (_i = (int)(0); (step173 > 0 && _i <= limit173) || (step173 < 0 && _i >= limit173); _i += step173) {
 //BA.debugLineNum = 213;BA.debugLine="Dim cbx As CheckBox";
_cbx = new anywheresoftware.b4a.objects.CompoundButtonWrapper.CheckBoxWrapper();
 //BA.debugLineNum = 214;BA.debugLine="cbx.Initialize(\"cbxDrawCurve\")";
_cbx.Initialize(mostCurrent.activityBA,"cbxDrawCurve");
 //BA.debugLineNum = 215;BA.debugLine="pnlCurveTools.AddView(cbx, 6dip + i * 100dip, 0, 60dip, 50dip)";
mostCurrent._pnlcurvetools.AddView((android.view.View)(_cbx.getObject()),(int)(anywheresoftware.b4a.keywords.Common.DipToCurrent((int)(6))+_i*anywheresoftware.b4a.keywords.Common.DipToCurrent((int)(100))),(int)(0),anywheresoftware.b4a.keywords.Common.DipToCurrent((int)(60)),anywheresoftware.b4a.keywords.Common.DipToCurrent((int)(50)));
 //BA.debugLineNum = 217;BA.debugLine="labelcheckbox(i).Initialize(\"labelcheckbox\")";
mostCurrent._labelcheckbox[_i].Initialize(mostCurrent.activityBA,"labelcheckbox");
 //BA.debugLineNum = 218;BA.debugLine="pnlCurveTools.AddView(labelcheckbox(i), 56dip + i * 100dip, 0, 40dip, 50dip)";
mostCurrent._pnlcurvetools.AddView((android.view.View)(mostCurrent._labelcheckbox[_i].getObject()),(int)(anywheresoftware.b4a.keywords.Common.DipToCurrent((int)(56))+_i*anywheresoftware.b4a.keywords.Common.DipToCurrent((int)(100))),(int)(0),anywheresoftware.b4a.keywords.Common.DipToCurrent((int)(40)),anywheresoftware.b4a.keywords.Common.DipToCurrent((int)(50)));
 //BA.debugLineNum = 220;BA.debugLine="cbx.Tag = i";
_cbx.setTag((Object)(_i));
 //BA.debugLineNum = 221;BA.debugLine="cbx.Checked = True";
_cbx.setChecked(anywheresoftware.b4a.keywords.Common.True);
 //BA.debugLineNum = 222;BA.debugLine="labelcheckbox(i).Tag=i";
mostCurrent._labelcheckbox[_i].setTag((Object)(_i));
 //BA.debugLineNum = 223;BA.debugLine="checkboxtags(i)=i";
mostCurrent._checkboxtags[_i] = BA.NumberToString(_i);
 //BA.debugLineNum = 224;BA.debugLine="labelcheckbox(i).Text=choselist.Get(i)";
mostCurrent._labelcheckbox[_i].setText(mostCurrent._choselist.Get(_i));
 //BA.debugLineNum = 225;BA.debugLine="labelcheckbox(i).Gravity=Bit.Or(Gravity.LEFT,Gravity.CENTER_VERTICAL)";
mostCurrent._labelcheckbox[_i].setGravity(anywheresoftware.b4a.keywords.Common.Bit.Or(anywheresoftware.b4a.keywords.Common.Gravity.LEFT,anywheresoftware.b4a.keywords.Common.Gravity.CENTER_VERTICAL));
 //BA.debugLineNum = 227;BA.debugLine="vals(i).Initialize(\"\")";
mostCurrent._vals[_i].Initialize(mostCurrent.activityBA,"");
 //BA.debugLineNum = 228;BA.debugLine="Activity.AddView(vals(i),Activity.Width-60dip, 10%y+i*15%y,100dip,30dip)";
mostCurrent._activity.AddView((android.view.View)(mostCurrent._vals[_i].getObject()),(int)(mostCurrent._activity.getWidth()-anywheresoftware.b4a.keywords.Common.DipToCurrent((int)(60))),(int)(anywheresoftware.b4a.keywords.Common.PerYToCurrent((float)(10),mostCurrent.activityBA)+_i*anywheresoftware.b4a.keywords.Common.PerYToCurrent((float)(15),mostCurrent.activityBA)),anywheresoftware.b4a.keywords.Common.DipToCurrent((int)(100)),anywheresoftware.b4a.keywords.Common.DipToCurrent((int)(30)));
 //BA.debugLineNum = 229;BA.debugLine="vals(i).Gravity=Bit.Or(Gravity.LEFT,Gravity.CENTER_VERTICAL)";
mostCurrent._vals[_i].setGravity(anywheresoftware.b4a.keywords.Common.Bit.Or(anywheresoftware.b4a.keywords.Common.Gravity.LEFT,anywheresoftware.b4a.keywords.Common.Gravity.CENTER_VERTICAL));
 }
};
 //BA.debugLineNum = 231;BA.debugLine="labelcheckbox(0).TextColor=Colors.Red";
mostCurrent._labelcheckbox[(int)(0)].setTextColor(anywheresoftware.b4a.keywords.Common.Colors.Red);
 //BA.debugLineNum = 232;BA.debugLine="labelcheckbox(1).TextColor=Colors.blue";
mostCurrent._labelcheckbox[(int)(1)].setTextColor(anywheresoftware.b4a.keywords.Common.Colors.Blue);
 //BA.debugLineNum = 233;BA.debugLine="labelcheckbox(2).TextColor=Colors.Green";
mostCurrent._labelcheckbox[(int)(2)].setTextColor(anywheresoftware.b4a.keywords.Common.Colors.Green);
 //BA.debugLineNum = 234;BA.debugLine="labelcheckbox(3).TextColor=Colors.Magenta";
mostCurrent._labelcheckbox[(int)(3)].setTextColor(anywheresoftware.b4a.keywords.Common.Colors.Magenta);
 //BA.debugLineNum = 236;BA.debugLine="ScopeMode=\"ROLL\"";
_scopemode = "ROLL";
 //BA.debugLineNum = 237;BA.debugLine="End Sub";
return "";
}
public static String  _activity_pause(boolean _userclosed) throws Exception{
 //BA.debugLineNum = 243;BA.debugLine="Sub Activity_Pause (UserClosed As Boolean)";
 //BA.debugLineNum = 244;BA.debugLine="btnStop_Click";
_btnstop_click();
 //BA.debugLineNum = 245;BA.debugLine="Main.return_from_cli=True";
mostCurrent._main._return_from_cli = anywheresoftware.b4a.keywords.Common.True;
 //BA.debugLineNum = 246;BA.debugLine="StartActivity(Main)";
anywheresoftware.b4a.keywords.Common.StartActivity(mostCurrent.activityBA,(Object)(mostCurrent._main.getObject()));
 //BA.debugLineNum = 247;BA.debugLine="Activity.Finish";
mostCurrent._activity.Finish();
 //BA.debugLineNum = 248;BA.debugLine="End Sub";
return "";
}
public static String  _activity_resume() throws Exception{
 //BA.debugLineNum = 239;BA.debugLine="Sub Activity_Resume";
 //BA.debugLineNum = 240;BA.debugLine="InitGrid";
_initgrid();
 //BA.debugLineNum = 241;BA.debugLine="End Sub";
return "";
}
public static String  _btnsingleshot_click() throws Exception{
 //BA.debugLineNum = 293;BA.debugLine="Sub btnSingleShot_Click";
 //BA.debugLineNum = 294;BA.debugLine="Timer1.Enabled = True";
_timer1.setEnabled(anywheresoftware.b4a.keywords.Common.True);
 //BA.debugLineNum = 295;BA.debugLine="SingleShot = True";
_singleshot = anywheresoftware.b4a.keywords.Common.True;
 //BA.debugLineNum = 296;BA.debugLine="Stopped = False";
_stopped = anywheresoftware.b4a.keywords.Common.False;
 //BA.debugLineNum = 297;BA.debugLine="ii = -1";
_ii = (int)(-1);
 //BA.debugLineNum = 298;BA.debugLine="xx = -dx";
_xx = (float)(-_dx);
 //BA.debugLineNum = 299;BA.debugLine="EraseCurves";
_erasecurves();
 //BA.debugLineNum = 300;BA.debugLine="End Sub";
return "";
}
public static String  _btnstart_click() throws Exception{
 //BA.debugLineNum = 277;BA.debugLine="Sub btnStart_Click";
 //BA.debugLineNum = 278;BA.debugLine="Timer1.Enabled = True";
_timer1.setEnabled(anywheresoftware.b4a.keywords.Common.True);
 //BA.debugLineNum = 279;BA.debugLine="SingleShot = False";
_singleshot = anywheresoftware.b4a.keywords.Common.False;
 //BA.debugLineNum = 280;BA.debugLine="Stopped = False";
_stopped = anywheresoftware.b4a.keywords.Common.False;
 //BA.debugLineNum = 281;BA.debugLine="ii = 100";
_ii = (int)(100);
 //BA.debugLineNum = 282;BA.debugLine="xx = -dx";
_xx = (float)(-_dx);
 //BA.debugLineNum = 283;BA.debugLine="EraseCurves";
_erasecurves();
 //BA.debugLineNum = 284;BA.debugLine="id=0";
_id = (int)(0);
 //BA.debugLineNum = 285;BA.debugLine="End Sub";
return "";
}
public static String  _btnstop_click() throws Exception{
 //BA.debugLineNum = 287;BA.debugLine="Sub btnStop_Click";
 //BA.debugLineNum = 288;BA.debugLine="Timer1.Enabled = False";
_timer1.setEnabled(anywheresoftware.b4a.keywords.Common.False);
 //BA.debugLineNum = 289;BA.debugLine="SingleShot = False";
_singleshot = anywheresoftware.b4a.keywords.Common.False;
 //BA.debugLineNum = 290;BA.debugLine="Stopped = True";
_stopped = anywheresoftware.b4a.keywords.Common.True;
 //BA.debugLineNum = 291;BA.debugLine="End Sub";
return "";
}
public static String  _cbxdrawcurve_checkedchange(boolean _checked) throws Exception{
anywheresoftware.b4a.objects.CompoundButtonWrapper.CheckBoxWrapper _cbx = null;
 //BA.debugLineNum = 560;BA.debugLine="Sub cbxDrawCurve_CheckedChange(Checked As Boolean)";
 //BA.debugLineNum = 561;BA.debugLine="Dim cbx As CheckBox";
_cbx = new anywheresoftware.b4a.objects.CompoundButtonWrapper.CheckBoxWrapper();
 //BA.debugLineNum = 562;BA.debugLine="cbx = Sender";
_cbx.setObject((android.widget.CheckBox)(anywheresoftware.b4a.keywords.Common.Sender(mostCurrent.activityBA)));
 //BA.debugLineNum = 563;BA.debugLine="Curve(cbx.Tag).Draw = Checked";
_curve[(int)(BA.ObjectToNumber(_cbx.getTag()))].Draw = _checked;
 //BA.debugLineNum = 564;BA.debugLine="End Sub";
return "";
}
public static String  _dispvalues(int _x) throws Exception{
int _i = 0;
 //BA.debugLineNum = 611;BA.debugLine="Sub DispValues(x As Int)";
 //BA.debugLineNum = 612;BA.debugLine="Dim i As Int";
_i = 0;
 //BA.debugLineNum = 614;BA.debugLine="i = 100 / GridW * x";
_i = (int)(100/(double)_gridw*_x);
 //BA.debugLineNum = 615;BA.debugLine="lblValue0.Text = NumberFormat(CurveVal(0, i), 1, 6)";
mostCurrent._lblvalue0.setText((Object)(anywheresoftware.b4a.keywords.Common.NumberFormat(_curveval[(int)(0)][_i],(int)(1),(int)(6))));
 //BA.debugLineNum = 616;BA.debugLine="lblValue1.Text = NumberFormat(CurveVal(1, i), 1, 6)";
mostCurrent._lblvalue1.setText((Object)(anywheresoftware.b4a.keywords.Common.NumberFormat(_curveval[(int)(1)][_i],(int)(1),(int)(6))));
 //BA.debugLineNum = 617;BA.debugLine="lblValue2.Text = NumberFormat(CurveVal(2, i), 1, 6)";
mostCurrent._lblvalue2.setText((Object)(anywheresoftware.b4a.keywords.Common.NumberFormat(_curveval[(int)(2)][_i],(int)(1),(int)(6))));
 //BA.debugLineNum = 618;BA.debugLine="lblValue3.Text = NumberFormat(CurveVal(3, i), 1, 6)";
mostCurrent._lblvalue3.setText((Object)(anywheresoftware.b4a.keywords.Common.NumberFormat(_curveval[(int)(3)][_i],(int)(1),(int)(6))));
 //BA.debugLineNum = 619;BA.debugLine="End Sub";
return "";
}
public static String  _drawcursor(float _x) throws Exception{
 //BA.debugLineNum = 604;BA.debugLine="Sub DrawCursor(x As Float)";
 //BA.debugLineNum = 605;BA.debugLine="cvsCursor.DrawLine(cx, 0, cx, GridH, Colors.Transparent, 1)";
mostCurrent._cvscursor.DrawLine(_cx,(float)(0),_cx,(float)(_gridh),anywheresoftware.b4a.keywords.Common.Colors.Transparent,(float)(1));
 //BA.debugLineNum = 606;BA.debugLine="cx = x";
_cx = _x;
 //BA.debugLineNum = 607;BA.debugLine="cvsCursor.DrawLine(cx, 0, cx, GridH, Colors.Red, 1)";
mostCurrent._cvscursor.DrawLine(_cx,(float)(0),_cx,(float)(_gridh),anywheresoftware.b4a.keywords.Common.Colors.Red,(float)(1));
 //BA.debugLineNum = 608;BA.debugLine="pnlCursor.Invalidate";
mostCurrent._pnlcursor.Invalidate();
 //BA.debugLineNum = 609;BA.debugLine="End Sub";
return "";
}
public static String  _drawcurves() throws Exception{
int _i = 0;
int _j = 0;
anywheresoftware.b4a.objects.drawable.CanvasWrapper.RectWrapper _r1 = null;
anywheresoftware.b4a.objects.drawable.CanvasWrapper.RectWrapper _r2 = null;
float _x = 0f;
float[] _yy1 = null;
float[] _yy2 = null;
 //BA.debugLineNum = 367;BA.debugLine="Sub DrawCurves";
 //BA.debugLineNum = 368;BA.debugLine="Dim i, j As Int";
_i = 0;
_j = 0;
 //BA.debugLineNum = 369;BA.debugLine="Dim r1, r2 As Rect";
_r1 = new anywheresoftware.b4a.objects.drawable.CanvasWrapper.RectWrapper();
_r2 = new anywheresoftware.b4a.objects.drawable.CanvasWrapper.RectWrapper();
 //BA.debugLineNum = 370;BA.debugLine="Dim x, yy1(4), yy2(4) As Float";
_x = 0f;
_yy1 = new float[(int)(4)];
;
_yy2 = new float[(int)(4)];
;
 //BA.debugLineNum = 372;BA.debugLine="If SingleShot = False Then";
if (_singleshot==anywheresoftware.b4a.keywords.Common.False) { 
 //BA.debugLineNum = 374;BA.debugLine="If ScopeRolling = True Then";
if (_scoperolling==anywheresoftware.b4a.keywords.Common.True) { 
 //BA.debugLineNum = 375;BA.debugLine="cvsGraph.DrawRect(rectGrid, Colors.Transparent, True, 1)";
mostCurrent._cvsgraph.DrawRect((android.graphics.Rect)(mostCurrent._rectgrid.getObject()),anywheresoftware.b4a.keywords.Common.Colors.Transparent,anywheresoftware.b4a.keywords.Common.True,(float)(1));
 //BA.debugLineNum = 376;BA.debugLine="For i = 0 To CurvesNb";
{
final double step315 = 1;
final double limit315 = _curvesnb;
for (_i = (int)(0); (step315 > 0 && _i <= limit315) || (step315 < 0 && _i >= limit315); _i += step315) {
 //BA.debugLineNum = 377;BA.debugLine="If Curve(i).Draw = True Then";
if (_curve[_i].Draw==anywheresoftware.b4a.keywords.Common.True) { 
 //BA.debugLineNum = 378;BA.debugLine="yy1(i) = GridYm + (-Curve(i).offset - CurveVal(i, 0)) * Curve(i).Scale";
_yy1[_i] = (float)(_gridym+(-_curve[_i].offset-_curveval[_i][(int)(0)])*_curve[_i].Scale);
 //BA.debugLineNum = 379;BA.debugLine="For j = 1 To 99";
{
final double step318 = 1;
final double limit318 = (int)(99);
for (_j = (int)(1); (step318 > 0 && _j <= limit318) || (step318 < 0 && _j >= limit318); _j += step318) {
 //BA.debugLineNum = 380;BA.debugLine="x = j * dx";
_x = (float)(_j*_dx);
 //BA.debugLineNum = 381;BA.debugLine="yy2(i) = GridYm + (-Curve(i).offset - CurveVal(i, j)) * Curve(i).Scale";
_yy2[_i] = (float)(_gridym+(-_curve[_i].offset-_curveval[_i][_j])*_curve[_i].Scale);
 //BA.debugLineNum = 382;BA.debugLine="cvsGraph.DrawLine(x - dx, yy1(i), x, yy2(i), Curve(i).Color, Curve(i).Width)";
mostCurrent._cvsgraph.DrawLine((float)(_x-_dx),_yy1[_i],_x,_yy2[_i],_curve[_i].Color,_curve[_i].Width);
 //BA.debugLineNum = 383;BA.debugLine="yy1(i) = yy2(i)";
_yy1[_i] = _yy2[_i];
 }
};
 };
 }
};
 };
 };
 //BA.debugLineNum = 390;BA.debugLine="For i = 0 To CurvesNb";
{
final double step328 = 1;
final double limit328 = _curvesnb;
for (_i = (int)(0); (step328 > 0 && _i <= limit328) || (step328 < 0 && _i >= limit328); _i += step328) {
 //BA.debugLineNum = 391;BA.debugLine="If Curve(i).Draw = True Then";
if (_curve[_i].Draw==anywheresoftware.b4a.keywords.Common.True) { 
 //BA.debugLineNum = 392;BA.debugLine="y2(i) = GridYm + (-Curve(i).offset - CurveVal(i, ii)) * Curve(i).Scale";
_y2[_i] = (float)(_gridym+(-_curve[_i].offset-_curveval[_i][_ii])*_curve[_i].Scale);
 //BA.debugLineNum = 393;BA.debugLine="If ii > 0 Then";
if (_ii>0) { 
 //BA.debugLineNum = 394;BA.debugLine="cvsGraph.DrawLine(xx - dx, y1(i), xx, y2(i), Curve(i).Color, Curve(i).Width)";
mostCurrent._cvsgraph.DrawLine((float)(_xx-_dx),_y1[_i],_xx,_y2[_i],_curve[_i].Color,_curve[_i].Width);
 };
 //BA.debugLineNum = 396;BA.debugLine="y1(i) = y2(i)";
_y1[_i] = _y2[_i];
 };
 }
};
 //BA.debugLineNum = 399;BA.debugLine="pnlGraph.Invalidate";
mostCurrent._pnlgraph.Invalidate();
 //BA.debugLineNum = 400;BA.debugLine="DoEvents";
anywheresoftware.b4a.keywords.Common.DoEvents();
 //BA.debugLineNum = 401;BA.debugLine="End Sub";
return "";
}
public static String  _edtoffset_focuschanged(boolean _hasfocus) throws Exception{
anywheresoftware.b4a.objects.EditTextWrapper _edt = null;
double _val = 0;
 //BA.debugLineNum = 303;BA.debugLine="Sub edtOffset_FocusChanged (HasFocus As Boolean)";
 //BA.debugLineNum = 304;BA.debugLine="Dim edt As EditText";
_edt = new anywheresoftware.b4a.objects.EditTextWrapper();
 //BA.debugLineNum = 305;BA.debugLine="Dim val As Double";
_val = 0;
 //BA.debugLineNum = 307;BA.debugLine="If HasFocus = False Then";
if (_hasfocus==anywheresoftware.b4a.keywords.Common.False) { 
 //BA.debugLineNum = 308;BA.debugLine="edt = Sender";
_edt.setObject((android.widget.EditText)(anywheresoftware.b4a.keywords.Common.Sender(mostCurrent.activityBA)));
 //BA.debugLineNum = 309;BA.debugLine="Curve(edt.Tag).offset = edt.Text";
_curve[(int)(BA.ObjectToNumber(_edt.getTag()))].offset = (double)(Double.parseDouble(_edt.getText()));
 };
 //BA.debugLineNum = 311;BA.debugLine="End Sub";
return "";
}
public static String  _erasecurves() throws Exception{
 //BA.debugLineNum = 556;BA.debugLine="Sub EraseCurves";
 //BA.debugLineNum = 557;BA.debugLine="cvsGraph.DrawRect(rectGrid, Colors.Transparent, True, 1)";
mostCurrent._cvsgraph.DrawRect((android.graphics.Rect)(mostCurrent._rectgrid.getObject()),anywheresoftware.b4a.keywords.Common.Colors.Transparent,anywheresoftware.b4a.keywords.Common.True,(float)(1));
 //BA.debugLineNum = 558;BA.debugLine="End Sub";
return "";
}
public static String  _getvalues() throws Exception{
char[] _buffer = null;
int _alt = 0;
String _ret = "";
int[] _ints = null;
char[] _buff2 = null;
int _i = 0;
int[] _ints2 = null;
int _quien = 0;
String _s = "";
 //BA.debugLineNum = 403;BA.debugLine="Sub GetValues";
 //BA.debugLineNum = 404;BA.debugLine="If Main.connected Then";
if (mostCurrent._main._connected) { 
 //BA.debugLineNum = 405;BA.debugLine="If Main.TextReader1.Ready Then 'check if there is any data waiting to be read";
if (mostCurrent._main._textreader1.Ready()) { 
 //BA.debugLineNum = 407;BA.debugLine="Dim buffer(155) As Char";
_buffer = new char[(int)(155)];
;
 //BA.debugLineNum = 408;BA.debugLine="Dim alt As Int";
_alt = 0;
 //BA.debugLineNum = 409;BA.debugLine="ret=Main.TextReader1.read(buffer,0,buffer.length)";
_ret = BA.NumberToString(mostCurrent._main._textreader1.Read(_buffer,(int)(0),_buffer.length));
 //BA.debugLineNum = 410;BA.debugLine="Dim ints(100) As Int";
_ints = new int[(int)(100)];
;
 //BA.debugLineNum = 411;BA.debugLine="Dim buff2(100) As Char";
_buff2 = new char[(int)(100)];
;
 //BA.debugLineNum = 412;BA.debugLine="If Main.protocol=0 Then";
if (mostCurrent._main._protocol==0) { 
 //BA.debugLineNum = 413;BA.debugLine="For i=0 To 23";
{
final double step349 = 1;
final double limit349 = (int)(23);
for (_i = (int)(0); (step349 > 0 && _i <= limit349) || (step349 < 0 && _i >= limit349); _i += step349) {
 //BA.debugLineNum = 414;BA.debugLine="ints(i)=Asc(buffer(i))";
_ints[_i] = anywheresoftware.b4a.keywords.Common.Asc(_buffer[_i]);
 //BA.debugLineNum = 415;BA.debugLine="buff2(i)=buffer(i)";
_buff2[_i] = _buffer[_i];
 }
};
 }else {
 //BA.debugLineNum = 418;BA.debugLine="Dim ints2(100) As Int";
_ints2 = new int[(int)(100)];
;
 //BA.debugLineNum = 419;BA.debugLine="For i=0 To ret";
{
final double step355 = 1;
final double limit355 = (int)(Double.parseDouble(_ret));
for (_i = (int)(0); (step355 > 0 && _i <= limit355) || (step355 < 0 && _i >= limit355); _i += step355) {
 //BA.debugLineNum = 420;BA.debugLine="ints2(i)=Asc(buffer(i))";
_ints2[_i] = anywheresoftware.b4a.keywords.Common.Asc(_buffer[_i]);
 }
};
 //BA.debugLineNum = 422;BA.debugLine="stateMSP=ints2(4)";
_statemsp = _ints2[(int)(4)];
 //BA.debugLineNum = 424;BA.debugLine="If stateMSP>99 Then";
if (_statemsp>99) { 
 //BA.debugLineNum = 425;BA.debugLine="Select stateMSP";
switch (BA.switchObjectToInt(_statemsp,(int)(Double.parseDouble(_msp_raw_imu)),(int)(Double.parseDouble(_msp_attitude)),(int)(Double.parseDouble(_msp_altitude)))) {
case 0:
 //BA.debugLineNum = 427;BA.debugLine="stateMSP = 0";
_statemsp = (int)(0);
 //BA.debugLineNum = 428;BA.debugLine="For i=0 To 19";
{
final double step363 = 1;
final double limit363 = (int)(19);
for (_i = (int)(0); (step363 > 0 && _i <= limit363) || (step363 < 0 && _i >= limit363); _i += step363) {
 //BA.debugLineNum = 429;BA.debugLine="ints(i)=ints2(i+5)";
_ints[_i] = _ints2[(int)(_i+5)];
 }
};
 break;
case 1:
 //BA.debugLineNum = 432;BA.debugLine="stateMSP = 0";
_statemsp = (int)(0);
 //BA.debugLineNum = 433;BA.debugLine="ints(22)=ints2(9)";
_ints[(int)(22)] = _ints2[(int)(9)];
 //BA.debugLineNum = 434;BA.debugLine="ints(23)=ints2(10)";
_ints[(int)(23)] = _ints2[(int)(10)];
 break;
case 2:
 //BA.debugLineNum = 436;BA.debugLine="stateMSP = 0";
_statemsp = (int)(0);
 //BA.debugLineNum = 437;BA.debugLine="alt = read32(ints2(5),ints2(6),ints2(7),ints2(8))";
_alt = _read32(_ints2[(int)(5)],_ints2[(int)(6)],_ints2[(int)(7)],_ints2[(int)(8)]);
 break;
}
;
 };
 };
 //BA.debugLineNum = 442;BA.debugLine="For quien= 0 To 3";
{
final double step376 = 1;
final double limit376 = (int)(3);
for (_quien = (int)(0); (step376 > 0 && _quien <= limit376) || (step376 < 0 && _quien >= limit376); _quien += step376) {
 //BA.debugLineNum = 443;BA.debugLine="Dim s As String";
_s = "";
 //BA.debugLineNum = 444;BA.debugLine="s=checkboxtags(quien)";
_s = mostCurrent._checkboxtags[_quien];
 //BA.debugLineNum = 445;BA.debugLine="Select s";
switch (BA.switchObjectToInt(_s,"0","1","2","3","4","5","6","7","8","9","10")) {
case 0:
 //BA.debugLineNum = 447;BA.debugLine="If Bit.And(ints(3),128)=128 Then";
if (anywheresoftware.b4a.keywords.Common.Bit.And(_ints[(int)(3)],(int)(128))==128) { 
 //BA.debugLineNum = 449;BA.debugLine="CurveVal(quien, ii) = read16(ints(2),Bit.Not(ints(3)))-255";
_curveval[_quien][_ii] = _read16(_ints[(int)(2)],anywheresoftware.b4a.keywords.Common.Bit.Not(_ints[(int)(3)]))-255;
 }else {
 //BA.debugLineNum = 451;BA.debugLine="CurveVal(quien,ii)=read16(ints(2),ints(3)) 'positivo";
_curveval[_quien][_ii] = _read16(_ints[(int)(2)],_ints[(int)(3)]);
 };
 break;
case 1:
 //BA.debugLineNum = 455;BA.debugLine="If Bit.And(ints(5),128)=128 Then";
if (anywheresoftware.b4a.keywords.Common.Bit.And(_ints[(int)(5)],(int)(128))==128) { 
 //BA.debugLineNum = 457;BA.debugLine="CurveVal(quien, ii) = read16(ints(4),Bit.Not(ints(5)))-255";
_curveval[_quien][_ii] = _read16(_ints[(int)(4)],anywheresoftware.b4a.keywords.Common.Bit.Not(_ints[(int)(5)]))-255;
 }else {
 //BA.debugLineNum = 459;BA.debugLine="CurveVal(quien,ii)=read16(ints(4),ints(5)) 'positivo";
_curveval[_quien][_ii] = _read16(_ints[(int)(4)],_ints[(int)(5)]);
 };
 break;
case 2:
 //BA.debugLineNum = 463;BA.debugLine="If Bit.And(ints(7),128)=128 Then";
if (anywheresoftware.b4a.keywords.Common.Bit.And(_ints[(int)(7)],(int)(128))==128) { 
 //BA.debugLineNum = 465;BA.debugLine="CurveVal(quien, ii) = read16(ints(6),Bit.Not(ints(7)))-255";
_curveval[_quien][_ii] = _read16(_ints[(int)(6)],anywheresoftware.b4a.keywords.Common.Bit.Not(_ints[(int)(7)]))-255;
 }else {
 //BA.debugLineNum = 467;BA.debugLine="CurveVal(quien,ii)=read16(ints(6),ints(7)) 'positivo";
_curveval[_quien][_ii] = _read16(_ints[(int)(6)],_ints[(int)(7)]);
 };
 break;
case 3:
 //BA.debugLineNum = 471;BA.debugLine="If Bit.And(ints(9),128)=128 Then";
if (anywheresoftware.b4a.keywords.Common.Bit.And(_ints[(int)(9)],(int)(128))==128) { 
 //BA.debugLineNum = 473;BA.debugLine="CurveVal(quien, ii) = (read16(ints(8),Bit.Not(ints(9)))-255)/8";
_curveval[_quien][_ii] = (_read16(_ints[(int)(8)],anywheresoftware.b4a.keywords.Common.Bit.Not(_ints[(int)(9)]))-255)/(double)8;
 }else {
 //BA.debugLineNum = 475;BA.debugLine="CurveVal(quien,ii)=(read16(ints(8),ints(9)))/8 'positivo";
_curveval[_quien][_ii] = (_read16(_ints[(int)(8)],_ints[(int)(9)]))/(double)8;
 };
 break;
case 4:
 //BA.debugLineNum = 478;BA.debugLine="If Bit.And(ints(11),128)=128 Then";
if (anywheresoftware.b4a.keywords.Common.Bit.And(_ints[(int)(11)],(int)(128))==128) { 
 //BA.debugLineNum = 480;BA.debugLine="CurveVal(quien, ii) = (read16(ints(10),Bit.Not(ints(11)))-255)/8";
_curveval[_quien][_ii] = (_read16(_ints[(int)(10)],anywheresoftware.b4a.keywords.Common.Bit.Not(_ints[(int)(11)]))-255)/(double)8;
 }else {
 //BA.debugLineNum = 482;BA.debugLine="CurveVal(quien,ii)=(read16(ints(10),ints(11)))/8 'positivo";
_curveval[_quien][_ii] = (_read16(_ints[(int)(10)],_ints[(int)(11)]))/(double)8;
 };
 break;
case 5:
 //BA.debugLineNum = 485;BA.debugLine="If Bit.And(ints(13),128)=128 Then";
if (anywheresoftware.b4a.keywords.Common.Bit.And(_ints[(int)(13)],(int)(128))==128) { 
 //BA.debugLineNum = 487;BA.debugLine="CurveVal(quien, ii) = (read16(ints(12),Bit.Not(ints(13)))-255)/8";
_curveval[_quien][_ii] = (_read16(_ints[(int)(12)],anywheresoftware.b4a.keywords.Common.Bit.Not(_ints[(int)(13)]))-255)/(double)8;
 }else {
 //BA.debugLineNum = 489;BA.debugLine="CurveVal(quien,ii)=(read16(ints(12),ints(13)))/8 'positivo";
_curveval[_quien][_ii] = (_read16(_ints[(int)(12)],_ints[(int)(13)]))/(double)8;
 };
 break;
case 6:
 //BA.debugLineNum = 492;BA.debugLine="If Bit.And(ints(15),128)=128 Then";
if (anywheresoftware.b4a.keywords.Common.Bit.And(_ints[(int)(15)],(int)(128))==128) { 
 //BA.debugLineNum = 494;BA.debugLine="CurveVal(quien, ii) = (read16(ints(14),Bit.Not(ints(15)))-255)/3";
_curveval[_quien][_ii] = (_read16(_ints[(int)(14)],anywheresoftware.b4a.keywords.Common.Bit.Not(_ints[(int)(15)]))-255)/(double)3;
 }else {
 //BA.debugLineNum = 496;BA.debugLine="CurveVal(quien,ii)=(read16(ints(14),ints(15)))/3 'positivo";
_curveval[_quien][_ii] = (_read16(_ints[(int)(14)],_ints[(int)(15)]))/(double)3;
 };
 break;
case 7:
 //BA.debugLineNum = 499;BA.debugLine="If Bit.And(ints(17),128)=128 Then";
if (anywheresoftware.b4a.keywords.Common.Bit.And(_ints[(int)(17)],(int)(128))==128) { 
 //BA.debugLineNum = 501;BA.debugLine="CurveVal(quien, ii) = (read16(ints(16),Bit.Not(ints(17)))-255)/3";
_curveval[_quien][_ii] = (_read16(_ints[(int)(16)],anywheresoftware.b4a.keywords.Common.Bit.Not(_ints[(int)(17)]))-255)/(double)3;
 }else {
 //BA.debugLineNum = 503;BA.debugLine="CurveVal(quien,ii)=(read16(ints(16),ints(17)))/3 'positivo";
_curveval[_quien][_ii] = (_read16(_ints[(int)(16)],_ints[(int)(17)]))/(double)3;
 };
 break;
case 8:
 //BA.debugLineNum = 506;BA.debugLine="If Bit.And(ints(19),128)=128 Then";
if (anywheresoftware.b4a.keywords.Common.Bit.And(_ints[(int)(19)],(int)(128))==128) { 
 //BA.debugLineNum = 508;BA.debugLine="CurveVal(quien, ii) = (read16(ints(18),Bit.Not(ints(19)))-255)/3";
_curveval[_quien][_ii] = (_read16(_ints[(int)(18)],anywheresoftware.b4a.keywords.Common.Bit.Not(_ints[(int)(19)]))-255)/(double)3;
 }else {
 //BA.debugLineNum = 510;BA.debugLine="CurveVal(quien,ii)=(read16(ints(18),ints(19)))/3 'positivo";
_curveval[_quien][_ii] = (_read16(_ints[(int)(18)],_ints[(int)(19)]))/(double)3;
 };
 break;
case 9:
 //BA.debugLineNum = 513;BA.debugLine="If Main.protocol=0 Then";
if (mostCurrent._main._protocol==0) { 
 //BA.debugLineNum = 514;BA.debugLine="If Bit.And(ints(21),128)=128 Then";
if (anywheresoftware.b4a.keywords.Common.Bit.And(_ints[(int)(21)],(int)(128))==128) { 
 //BA.debugLineNum = 516;BA.debugLine="CurveVal(quien, ii) = (read16(ints(20),Bit.Not(ints(21)))-255)/10";
_curveval[_quien][_ii] = (_read16(_ints[(int)(20)],anywheresoftware.b4a.keywords.Common.Bit.Not(_ints[(int)(21)]))-255)/(double)10;
 }else {
 //BA.debugLineNum = 518;BA.debugLine="CurveVal(quien,ii)=(read16(ints(20),ints(21)))/10 'positivo";
_curveval[_quien][_ii] = (_read16(_ints[(int)(20)],_ints[(int)(21)]))/(double)10;
 };
 }else {
 //BA.debugLineNum = 521;BA.debugLine="CurveVal(quien,ii)=alt";
_curveval[_quien][_ii] = _alt;
 };
 break;
case 10:
 //BA.debugLineNum = 524;BA.debugLine="If Bit.And(ints(23),128)=128 Then";
if (anywheresoftware.b4a.keywords.Common.Bit.And(_ints[(int)(23)],(int)(128))==128) { 
 //BA.debugLineNum = 526;BA.debugLine="CurveVal(quien, ii) = (read16(ints(22),Bit.Not(ints(23)))-255)";
_curveval[_quien][_ii] = (_read16(_ints[(int)(22)],anywheresoftware.b4a.keywords.Common.Bit.Not(_ints[(int)(23)]))-255);
 }else {
 //BA.debugLineNum = 528;BA.debugLine="CurveVal(quien,ii)=(read16(ints(22),ints(23))) 'positivo";
_curveval[_quien][_ii] = (_read16(_ints[(int)(22)],_ints[(int)(23)]));
 };
 break;
}
;
 //BA.debugLineNum = 532;BA.debugLine="vals(0).Text= labelcheckbox(0).Text & \"= \" & CurveVal(0,ii)";
mostCurrent._vals[(int)(0)].setText((Object)(mostCurrent._labelcheckbox[(int)(0)].getText()+"= "+BA.NumberToString(_curveval[(int)(0)][_ii])));
 //BA.debugLineNum = 533;BA.debugLine="vals(1).text=labelcheckbox(1).Text & \"= \" & CurveVal(1,ii)";
mostCurrent._vals[(int)(1)].setText((Object)(mostCurrent._labelcheckbox[(int)(1)].getText()+"= "+BA.NumberToString(_curveval[(int)(1)][_ii])));
 //BA.debugLineNum = 534;BA.debugLine="vals(2).Text=labelcheckbox(2).Text & \"= \" & CurveVal(2,ii)";
mostCurrent._vals[(int)(2)].setText((Object)(mostCurrent._labelcheckbox[(int)(2)].getText()+"= "+BA.NumberToString(_curveval[(int)(2)][_ii])));
 //BA.debugLineNum = 535;BA.debugLine="vals(3).Text=labelcheckbox(3).Text & \"= \" & CurveVal(3,ii)";
mostCurrent._vals[(int)(3)].setText((Object)(mostCurrent._labelcheckbox[(int)(3)].getText()+"= "+BA.NumberToString(_curveval[(int)(3)][_ii])));
 }
};
 }else {
 //BA.debugLineNum = 539;BA.debugLine="If Main.protocol = 0 Then";
if (mostCurrent._main._protocol==0) { 
 //BA.debugLineNum = 540;BA.debugLine="Main.TextWriter1.Write(\"M\")";
mostCurrent._main._textwriter1.Write("M");
 //BA.debugLineNum = 541;BA.debugLine="Main.TextWriter1.Flush";
mostCurrent._main._textwriter1.Flush();
 }else {
 //BA.debugLineNum = 544;BA.debugLine="Main.TextWriter1.Write(\"$M<\" & Chr(MSP_RAW_IMU))";
mostCurrent._main._textwriter1.Write("$M<"+String.valueOf(anywheresoftware.b4a.keywords.Common.Chr((int)(Double.parseDouble(_msp_raw_imu)))));
 //BA.debugLineNum = 545;BA.debugLine="Main.TextWriter1.Flush";
mostCurrent._main._textwriter1.Flush();
 };
 };
 };
 //BA.debugLineNum = 554;BA.debugLine="End Sub";
return "";
}

public static void initializeProcessGlobals() {
     main.initializeProcessGlobals();
}
public static String  _globals() throws Exception{
 //BA.debugLineNum = 68;BA.debugLine="Sub Globals";
 //BA.debugLineNum = 71;BA.debugLine="Dim btnStart, btnStop, btnSingleShot As Button";
mostCurrent._btnstart = new anywheresoftware.b4a.objects.ButtonWrapper();
mostCurrent._btnstop = new anywheresoftware.b4a.objects.ButtonWrapper();
mostCurrent._btnsingleshot = new anywheresoftware.b4a.objects.ButtonWrapper();
 //BA.debugLineNum = 72;BA.debugLine="Dim pnlOcilloscope, pnlScreen, pnlGraph, pnlCursor, pnlControl As Panel";
mostCurrent._pnlocilloscope = new anywheresoftware.b4a.objects.PanelWrapper();
mostCurrent._pnlscreen = new anywheresoftware.b4a.objects.PanelWrapper();
mostCurrent._pnlgraph = new anywheresoftware.b4a.objects.PanelWrapper();
mostCurrent._pnlcursor = new anywheresoftware.b4a.objects.PanelWrapper();
mostCurrent._pnlcontrol = new anywheresoftware.b4a.objects.PanelWrapper();
 //BA.debugLineNum = 73;BA.debugLine="Dim pnlCurveTools, pnlDispValues As Panel";
mostCurrent._pnlcurvetools = new anywheresoftware.b4a.objects.PanelWrapper();
mostCurrent._pnldispvalues = new anywheresoftware.b4a.objects.PanelWrapper();
 //BA.debugLineNum = 74;BA.debugLine="Dim cvsScreen, cvsGraph, cvsCursor As Canvas";
mostCurrent._cvsscreen = new anywheresoftware.b4a.objects.drawable.CanvasWrapper();
mostCurrent._cvsgraph = new anywheresoftware.b4a.objects.drawable.CanvasWrapper();
mostCurrent._cvscursor = new anywheresoftware.b4a.objects.drawable.CanvasWrapper();
 //BA.debugLineNum = 75;BA.debugLine="Dim rectScreen, rectGrid As Rect";
mostCurrent._rectscreen = new anywheresoftware.b4a.objects.drawable.CanvasWrapper.RectWrapper();
mostCurrent._rectgrid = new anywheresoftware.b4a.objects.drawable.CanvasWrapper.RectWrapper();
 //BA.debugLineNum = 76;BA.debugLine="Dim spnTimeScale As Spinner";
mostCurrent._spntimescale = new anywheresoftware.b4a.objects.SpinnerWrapper();
 //BA.debugLineNum = 77;BA.debugLine="Dim spnScale0, spnScale1, spnScale2, spnScale3 As Spinner";
mostCurrent._spnscale0 = new anywheresoftware.b4a.objects.SpinnerWrapper();
mostCurrent._spnscale1 = new anywheresoftware.b4a.objects.SpinnerWrapper();
mostCurrent._spnscale2 = new anywheresoftware.b4a.objects.SpinnerWrapper();
mostCurrent._spnscale3 = new anywheresoftware.b4a.objects.SpinnerWrapper();
 //BA.debugLineNum = 78;BA.debugLine="Dim lblScale0, lblScale1, lblScale2, lblScale3 As Label";
mostCurrent._lblscale0 = new anywheresoftware.b4a.objects.LabelWrapper();
mostCurrent._lblscale1 = new anywheresoftware.b4a.objects.LabelWrapper();
mostCurrent._lblscale2 = new anywheresoftware.b4a.objects.LabelWrapper();
mostCurrent._lblscale3 = new anywheresoftware.b4a.objects.LabelWrapper();
 //BA.debugLineNum = 79;BA.debugLine="Dim lblValue0, lblValue1, lblValue2, lblValue3 As Label";
mostCurrent._lblvalue0 = new anywheresoftware.b4a.objects.LabelWrapper();
mostCurrent._lblvalue1 = new anywheresoftware.b4a.objects.LabelWrapper();
mostCurrent._lblvalue2 = new anywheresoftware.b4a.objects.LabelWrapper();
mostCurrent._lblvalue3 = new anywheresoftware.b4a.objects.LabelWrapper();
 //BA.debugLineNum = 80;BA.debugLine="Dim lblOffset0, lblOffset1, lblOffset2, lblOffset3 As Label";
mostCurrent._lbloffset0 = new anywheresoftware.b4a.objects.LabelWrapper();
mostCurrent._lbloffset1 = new anywheresoftware.b4a.objects.LabelWrapper();
mostCurrent._lbloffset2 = new anywheresoftware.b4a.objects.LabelWrapper();
mostCurrent._lbloffset3 = new anywheresoftware.b4a.objects.LabelWrapper();
 //BA.debugLineNum = 81;BA.debugLine="Dim edtOffset0, edtOffset1, edtOffset2, edtOffset3 As EditText";
mostCurrent._edtoffset0 = new anywheresoftware.b4a.objects.EditTextWrapper();
mostCurrent._edtoffset1 = new anywheresoftware.b4a.objects.EditTextWrapper();
mostCurrent._edtoffset2 = new anywheresoftware.b4a.objects.EditTextWrapper();
mostCurrent._edtoffset3 = new anywheresoftware.b4a.objects.EditTextWrapper();
 //BA.debugLineNum = 82;BA.debugLine="Dim rbtScopeScope, rbtScopeMEM, rbtScopeROLL As RadioButton";
mostCurrent._rbtscopescope = new anywheresoftware.b4a.objects.CompoundButtonWrapper.RadioButtonWrapper();
mostCurrent._rbtscopemem = new anywheresoftware.b4a.objects.CompoundButtonWrapper.RadioButtonWrapper();
mostCurrent._rbtscoperoll = new anywheresoftware.b4a.objects.CompoundButtonWrapper.RadioButtonWrapper();
 //BA.debugLineNum = 83;BA.debugLine="Dim scvControl As ScrollView";
mostCurrent._scvcontrol = new anywheresoftware.b4a.objects.ScrollViewWrapper();
 //BA.debugLineNum = 84;BA.debugLine="Dim bmpRoll As Bitmap";
mostCurrent._bmproll = new anywheresoftware.b4a.objects.drawable.CanvasWrapper.BitmapWrapper();
 //BA.debugLineNum = 85;BA.debugLine="Dim choselist As List";
mostCurrent._choselist = new anywheresoftware.b4a.objects.collections.List();
 //BA.debugLineNum = 86;BA.debugLine="Dim labelcheckbox(4) As Label";
mostCurrent._labelcheckbox = new anywheresoftware.b4a.objects.LabelWrapper[(int)(4)];
{
int d0 = mostCurrent._labelcheckbox.length;
for (int i0 = 0;i0 < d0;i0++) {
mostCurrent._labelcheckbox[i0] = new anywheresoftware.b4a.objects.LabelWrapper();
}
}
;
 //BA.debugLineNum = 87;BA.debugLine="Dim checkboxtags(4) As String";
mostCurrent._checkboxtags = new String[(int)(4)];
java.util.Arrays.fill(mostCurrent._checkboxtags,"");
 //BA.debugLineNum = 88;BA.debugLine="Dim vals(4) As Label";
mostCurrent._vals = new anywheresoftware.b4a.objects.LabelWrapper[(int)(4)];
{
int d0 = mostCurrent._vals.length;
for (int i0 = 0;i0 < d0;i0++) {
mostCurrent._vals[i0] = new anywheresoftware.b4a.objects.LabelWrapper();
}
}
;
 //BA.debugLineNum = 89;BA.debugLine="Dim id As Int";
_id = 0;
 //BA.debugLineNum = 91;BA.debugLine="End Sub";
return "";
}
public static String  _initcalccurves() throws Exception{
 //BA.debugLineNum = 653;BA.debugLine="Sub InitCalcCurves";
 //BA.debugLineNum = 654;BA.debugLine="w(0) = 2 * cPI * 2.1";
_w[(int)(0)] = 2*anywheresoftware.b4a.keywords.Common.cPI*2.1;
 //BA.debugLineNum = 655;BA.debugLine="w(1) = 2 * cPI * 3.7";
_w[(int)(1)] = 2*anywheresoftware.b4a.keywords.Common.cPI*3.7;
 //BA.debugLineNum = 656;BA.debugLine="w(2) = 2 * cPI * 4.3";
_w[(int)(2)] = 2*anywheresoftware.b4a.keywords.Common.cPI*4.3;
 //BA.debugLineNum = 657;BA.debugLine="w(3) = 2 * cPI * 5.7";
_w[(int)(3)] = 2*anywheresoftware.b4a.keywords.Common.cPI*5.7;
 //BA.debugLineNum = 659;BA.debugLine="a(0) = 1.0";
_a[(int)(0)] = 1.0;
 //BA.debugLineNum = 660;BA.debugLine="a(1) = 2.0";
_a[(int)(1)] = 2.0;
 //BA.debugLineNum = 661;BA.debugLine="a(2) = -1.0";
_a[(int)(2)] = -1.0;
 //BA.debugLineNum = 662;BA.debugLine="a(3) = 1.5";
_a[(int)(3)] = 1.5;
 //BA.debugLineNum = 663;BA.debugLine="End Sub";
return "";
}
public static String  _initcurves() throws Exception{
 //BA.debugLineNum = 621;BA.debugLine="Sub InitCurves";
 //BA.debugLineNum = 622;BA.debugLine="Curve(0).Color = Colors.Red";
_curve[(int)(0)].Color = anywheresoftware.b4a.keywords.Common.Colors.Red;
 //BA.debugLineNum = 623;BA.debugLine="Curve(1).Color = Colors.Blue";
_curve[(int)(1)].Color = anywheresoftware.b4a.keywords.Common.Colors.Blue;
 //BA.debugLineNum = 624;BA.debugLine="Curve(2).Color = Colors.Green";
_curve[(int)(2)].Color = anywheresoftware.b4a.keywords.Common.Colors.Green;
 //BA.debugLineNum = 625;BA.debugLine="Curve(3).Color = Colors.magenta";
_curve[(int)(3)].Color = anywheresoftware.b4a.keywords.Common.Colors.Magenta;
 //BA.debugLineNum = 627;BA.debugLine="Curve(0).Width = 1dip";
_curve[(int)(0)].Width = (float)(anywheresoftware.b4a.keywords.Common.DipToCurrent((int)(1)));
 //BA.debugLineNum = 628;BA.debugLine="Curve(1).Width = 1dip";
_curve[(int)(1)].Width = (float)(anywheresoftware.b4a.keywords.Common.DipToCurrent((int)(1)));
 //BA.debugLineNum = 629;BA.debugLine="Curve(2).Width = 1dip";
_curve[(int)(2)].Width = (float)(anywheresoftware.b4a.keywords.Common.DipToCurrent((int)(1)));
 //BA.debugLineNum = 630;BA.debugLine="Curve(3).Width = 1dip";
_curve[(int)(3)].Width = (float)(anywheresoftware.b4a.keywords.Common.DipToCurrent((int)(1)));
 //BA.debugLineNum = 637;BA.debugLine="Curve(0).Scale = 20";
_curve[(int)(0)].Scale = 20;
 //BA.debugLineNum = 638;BA.debugLine="Curve(1).Scale = 20";
_curve[(int)(1)].Scale = 20;
 //BA.debugLineNum = 639;BA.debugLine="Curve(2).Scale = 20";
_curve[(int)(2)].Scale = 20;
 //BA.debugLineNum = 640;BA.debugLine="Curve(3).Scale = 20";
_curve[(int)(3)].Scale = 20;
 //BA.debugLineNum = 642;BA.debugLine="Curve(0).offset = 0";
_curve[(int)(0)].offset = 0;
 //BA.debugLineNum = 643;BA.debugLine="Curve(1).offset = 0";
_curve[(int)(1)].offset = 0;
 //BA.debugLineNum = 644;BA.debugLine="Curve(2).offset = 0";
_curve[(int)(2)].offset = 0;
 //BA.debugLineNum = 645;BA.debugLine="Curve(3).offset = 0";
_curve[(int)(3)].offset = 0;
 //BA.debugLineNum = 647;BA.debugLine="Curve(0).Draw = True";
_curve[(int)(0)].Draw = anywheresoftware.b4a.keywords.Common.True;
 //BA.debugLineNum = 648;BA.debugLine="Curve(1).Draw = True";
_curve[(int)(1)].Draw = anywheresoftware.b4a.keywords.Common.True;
 //BA.debugLineNum = 649;BA.debugLine="Curve(2).Draw = True";
_curve[(int)(2)].Draw = anywheresoftware.b4a.keywords.Common.True;
 //BA.debugLineNum = 650;BA.debugLine="Curve(3).Draw = True";
_curve[(int)(3)].Draw = anywheresoftware.b4a.keywords.Common.True;
 //BA.debugLineNum = 651;BA.debugLine="End Sub";
return "";
}
public static String  _initgrid() throws Exception{
int _i = 0;
float _x = 0f;
float _y = 0f;
 //BA.debugLineNum = 250;BA.debugLine="Sub InitGrid";
 //BA.debugLineNum = 251;BA.debugLine="Dim i As Int";
_i = 0;
 //BA.debugLineNum = 252;BA.debugLine="Dim x, y As Float";
_x = 0f;
_y = 0f;
 //BA.debugLineNum = 254;BA.debugLine="cvsScreen.DrawRect(rectScreen, ScreenCol, True, 1)";
mostCurrent._cvsscreen.DrawRect((android.graphics.Rect)(mostCurrent._rectscreen.getObject()),_screencol,anywheresoftware.b4a.keywords.Common.True,(float)(1));
 //BA.debugLineNum = 255;BA.debugLine="For i = 0 To NbDivY";
{
final double step208 = 1;
final double limit208 = _nbdivy;
for (_i = (int)(0); (step208 > 0 && _i <= limit208) || (step208 < 0 && _i >= limit208); _i += step208) {
 //BA.debugLineNum = 256;BA.debugLine="y = GridX0 + i * Div";
_y = (float)(_gridx0+_i*_div);
 //BA.debugLineNum = 257;BA.debugLine="cvsScreen.DrawLine(GridX0, y, GridX1, y, GridLineCol, 1dip)";
mostCurrent._cvsscreen.DrawLine((float)(_gridx0),_y,(float)(_gridx1),_y,_gridlinecol,(float)(anywheresoftware.b4a.keywords.Common.DipToCurrent((int)(1))));
 }
};
 //BA.debugLineNum = 260;BA.debugLine="For i = 0 To NbDivX";
{
final double step212 = 1;
final double limit212 = _nbdivx;
for (_i = (int)(0); (step212 > 0 && _i <= limit212) || (step212 < 0 && _i >= limit212); _i += step212) {
 //BA.debugLineNum = 261;BA.debugLine="x = GridY0 + i * Div";
_x = (float)(_gridy0+_i*_div);
 //BA.debugLineNum = 262;BA.debugLine="cvsScreen.DrawLine(x, GridY0, x, GridY1, GridLineCol, 1dip)";
mostCurrent._cvsscreen.DrawLine(_x,(float)(_gridy0),_x,(float)(_gridy1),_gridlinecol,(float)(anywheresoftware.b4a.keywords.Common.DipToCurrent((int)(1))));
 }
};
 //BA.debugLineNum = 264;BA.debugLine="pnlScreen.Invalidate";
mostCurrent._pnlscreen.Invalidate();
 //BA.debugLineNum = 266;BA.debugLine="cvsGraph.DrawRect(rectGrid, Colors.Transparent, True, 1)";
mostCurrent._cvsgraph.DrawRect((android.graphics.Rect)(mostCurrent._rectgrid.getObject()),anywheresoftware.b4a.keywords.Common.Colors.Transparent,anywheresoftware.b4a.keywords.Common.True,(float)(1));
 //BA.debugLineNum = 267;BA.debugLine="pnlGraph.Invalidate";
mostCurrent._pnlgraph.Invalidate();
 //BA.debugLineNum = 269;BA.debugLine="cvsCursor.DrawRect(rectGrid, Colors.Transparent, True, 1)";
mostCurrent._cvscursor.DrawRect((android.graphics.Rect)(mostCurrent._rectgrid.getObject()),anywheresoftware.b4a.keywords.Common.Colors.Transparent,anywheresoftware.b4a.keywords.Common.True,(float)(1));
 //BA.debugLineNum = 270;BA.debugLine="pnlCursor.Invalidate";
mostCurrent._pnlcursor.Invalidate();
 //BA.debugLineNum = 271;BA.debugLine="End Sub";
return "";
}
public static String  _initspinners() throws Exception{
int _i = 0;
 //BA.debugLineNum = 665;BA.debugLine="Sub InitSpinners";
 //BA.debugLineNum = 666;BA.debugLine="Dim i As Int";
_i = 0;
 //BA.debugLineNum = 679;BA.debugLine="SignalScale(0) = 1000";
_signalscale[(int)(0)] = 1000;
 //BA.debugLineNum = 680;BA.debugLine="SignalScale(1) = 500";
_signalscale[(int)(1)] = 500;
 //BA.debugLineNum = 681;BA.debugLine="SignalScale(2) = 200";
_signalscale[(int)(2)] = 200;
 //BA.debugLineNum = 682;BA.debugLine="SignalScale(3) = 100";
_signalscale[(int)(3)] = 100;
 //BA.debugLineNum = 683;BA.debugLine="SignalScale(4) = 50";
_signalscale[(int)(4)] = 50;
 //BA.debugLineNum = 684;BA.debugLine="SignalScale(5) = 10";
_signalscale[(int)(5)] = 10;
 //BA.debugLineNum = 685;BA.debugLine="SignalScale(6) = 5";
_signalscale[(int)(6)] = 5;
 //BA.debugLineNum = 686;BA.debugLine="SignalScale(7) = 2";
_signalscale[(int)(7)] = 2;
 //BA.debugLineNum = 687;BA.debugLine="SignalScale(8) = 1";
_signalscale[(int)(8)] = 1;
 //BA.debugLineNum = 688;BA.debugLine="SignalScale(9) = .5";
_signalscale[(int)(9)] = .5;
 //BA.debugLineNum = 690;BA.debugLine="spnScale0.Initialize(\"spnScale\")";
mostCurrent._spnscale0.Initialize(mostCurrent.activityBA,"spnScale");
 //BA.debugLineNum = 691;BA.debugLine="spnScale1.Initialize(\"spnScale\")";
mostCurrent._spnscale1.Initialize(mostCurrent.activityBA,"spnScale");
 //BA.debugLineNum = 692;BA.debugLine="spnScale2.Initialize(\"spnScale\")";
mostCurrent._spnscale2.Initialize(mostCurrent.activityBA,"spnScale");
 //BA.debugLineNum = 693;BA.debugLine="spnScale3.Initialize(\"spnScale\")";
mostCurrent._spnscale3.Initialize(mostCurrent.activityBA,"spnScale");
 //BA.debugLineNum = 694;BA.debugLine="Activity.AddView(spnScale0,Activity.Width-180dip, 10%y+0*15%y,100dip,40dip)";
mostCurrent._activity.AddView((android.view.View)(mostCurrent._spnscale0.getObject()),(int)(mostCurrent._activity.getWidth()-anywheresoftware.b4a.keywords.Common.DipToCurrent((int)(180))),(int)(anywheresoftware.b4a.keywords.Common.PerYToCurrent((float)(10),mostCurrent.activityBA)+0*anywheresoftware.b4a.keywords.Common.PerYToCurrent((float)(15),mostCurrent.activityBA)),anywheresoftware.b4a.keywords.Common.DipToCurrent((int)(100)),anywheresoftware.b4a.keywords.Common.DipToCurrent((int)(40)));
 //BA.debugLineNum = 695;BA.debugLine="Activity.AddView(spnScale1,Activity.Width-180dip, 10%y+1*15%y,100dip,40dip)";
mostCurrent._activity.AddView((android.view.View)(mostCurrent._spnscale1.getObject()),(int)(mostCurrent._activity.getWidth()-anywheresoftware.b4a.keywords.Common.DipToCurrent((int)(180))),(int)(anywheresoftware.b4a.keywords.Common.PerYToCurrent((float)(10),mostCurrent.activityBA)+1*anywheresoftware.b4a.keywords.Common.PerYToCurrent((float)(15),mostCurrent.activityBA)),anywheresoftware.b4a.keywords.Common.DipToCurrent((int)(100)),anywheresoftware.b4a.keywords.Common.DipToCurrent((int)(40)));
 //BA.debugLineNum = 696;BA.debugLine="Activity.AddView(spnScale2,Activity.Width-180dip, 10%y+2*15%y,100dip,40dip)";
mostCurrent._activity.AddView((android.view.View)(mostCurrent._spnscale2.getObject()),(int)(mostCurrent._activity.getWidth()-anywheresoftware.b4a.keywords.Common.DipToCurrent((int)(180))),(int)(anywheresoftware.b4a.keywords.Common.PerYToCurrent((float)(10),mostCurrent.activityBA)+2*anywheresoftware.b4a.keywords.Common.PerYToCurrent((float)(15),mostCurrent.activityBA)),anywheresoftware.b4a.keywords.Common.DipToCurrent((int)(100)),anywheresoftware.b4a.keywords.Common.DipToCurrent((int)(40)));
 //BA.debugLineNum = 697;BA.debugLine="Activity.AddView(spnScale3,Activity.Width-180dip, 10%y+3*15%y,100dip,40dip)";
mostCurrent._activity.AddView((android.view.View)(mostCurrent._spnscale3.getObject()),(int)(mostCurrent._activity.getWidth()-anywheresoftware.b4a.keywords.Common.DipToCurrent((int)(180))),(int)(anywheresoftware.b4a.keywords.Common.PerYToCurrent((float)(10),mostCurrent.activityBA)+3*anywheresoftware.b4a.keywords.Common.PerYToCurrent((float)(15),mostCurrent.activityBA)),anywheresoftware.b4a.keywords.Common.DipToCurrent((int)(100)),anywheresoftware.b4a.keywords.Common.DipToCurrent((int)(40)));
 //BA.debugLineNum = 698;BA.debugLine="spnScale0.tag=0";
mostCurrent._spnscale0.setTag((Object)(0));
 //BA.debugLineNum = 699;BA.debugLine="spnScale1.tag=1";
mostCurrent._spnscale1.setTag((Object)(1));
 //BA.debugLineNum = 700;BA.debugLine="spnScale2.tag=2";
mostCurrent._spnscale2.setTag((Object)(2));
 //BA.debugLineNum = 701;BA.debugLine="spnScale3.tag=3";
mostCurrent._spnscale3.setTag((Object)(3));
 //BA.debugLineNum = 703;BA.debugLine="For i = 0 To 9";
{
final double step579 = 1;
final double limit579 = (int)(9);
for (_i = (int)(0); (step579 > 0 && _i <= limit579) || (step579 < 0 && _i >= limit579); _i += step579) {
 //BA.debugLineNum = 704;BA.debugLine="spnScale0.Add(SignalScale(i))";
mostCurrent._spnscale0.Add(BA.NumberToString(_signalscale[_i]));
 //BA.debugLineNum = 705;BA.debugLine="spnScale1.Add(SignalScale(i))";
mostCurrent._spnscale1.Add(BA.NumberToString(_signalscale[_i]));
 //BA.debugLineNum = 706;BA.debugLine="spnScale2.Add(SignalScale(i))";
mostCurrent._spnscale2.Add(BA.NumberToString(_signalscale[_i]));
 //BA.debugLineNum = 707;BA.debugLine="spnScale3.Add(SignalScale(i))";
mostCurrent._spnscale3.Add(BA.NumberToString(_signalscale[_i]));
 }
};
 //BA.debugLineNum = 711;BA.debugLine="spnScale0.SelectedIndex = 3";
mostCurrent._spnscale0.setSelectedIndex((int)(3));
 //BA.debugLineNum = 712;BA.debugLine="spnScale1.SelectedIndex = 3";
mostCurrent._spnscale1.setSelectedIndex((int)(3));
 //BA.debugLineNum = 713;BA.debugLine="spnScale2.SelectedIndex = 3";
mostCurrent._spnscale2.setSelectedIndex((int)(3));
 //BA.debugLineNum = 714;BA.debugLine="spnScale3.SelectedIndex = 3";
mostCurrent._spnscale3.setSelectedIndex((int)(3));
 //BA.debugLineNum = 715;BA.debugLine="Curve(0).Scale = Div / spnScale0.SelectedItem";
_curve[(int)(0)].Scale = _div/(double)(double)(Double.parseDouble(mostCurrent._spnscale0.getSelectedItem()));
 //BA.debugLineNum = 716;BA.debugLine="Curve(1).Scale = Div / spnScale1.SelectedItem";
_curve[(int)(1)].Scale = _div/(double)(double)(Double.parseDouble(mostCurrent._spnscale1.getSelectedItem()));
 //BA.debugLineNum = 717;BA.debugLine="Curve(2).Scale = Div / spnScale2.SelectedItem";
_curve[(int)(2)].Scale = _div/(double)(double)(Double.parseDouble(mostCurrent._spnscale2.getSelectedItem()));
 //BA.debugLineNum = 718;BA.debugLine="Curve(3).Scale = Div / spnScale3.SelectedItem";
_curve[(int)(3)].Scale = _div/(double)(double)(Double.parseDouble(mostCurrent._spnscale3.getSelectedItem()));
 //BA.debugLineNum = 719;BA.debugLine="End Sub";
return "";
}
public static String  _labelcheckbox_click() throws Exception{
anywheresoftware.b4a.objects.LabelWrapper _who = null;
String _i = "";
 //BA.debugLineNum = 566;BA.debugLine="Sub labelcheckbox_Click";
 //BA.debugLineNum = 567;BA.debugLine="Dim who As Label";
_who = new anywheresoftware.b4a.objects.LabelWrapper();
 //BA.debugLineNum = 568;BA.debugLine="who=Sender";
_who.setObject((android.widget.TextView)(anywheresoftware.b4a.keywords.Common.Sender(mostCurrent.activityBA)));
 //BA.debugLineNum = 569;BA.debugLine="i=InputList(choselist, \"\", who.Tag)";
_i = BA.NumberToString(anywheresoftware.b4a.keywords.Common.InputList(mostCurrent._choselist,"",(int)(BA.ObjectToNumber(_who.getTag())),mostCurrent.activityBA));
 //BA.debugLineNum = 570;BA.debugLine="If i=DialogResponse.CANCEL Then";
if ((_i).equals(BA.NumberToString(anywheresoftware.b4a.keywords.Common.DialogResponse.CANCEL))) { 
 }else {
 //BA.debugLineNum = 572;BA.debugLine="checkboxtags(who.Tag)=i";
mostCurrent._checkboxtags[(int)(BA.ObjectToNumber(_who.getTag()))] = _i;
 //BA.debugLineNum = 573;BA.debugLine="who.Text=choselist.Get(i)";
_who.setText(mostCurrent._choselist.Get((int)(Double.parseDouble(_i))));
 };
 //BA.debugLineNum = 575;BA.debugLine="End Sub";
return "";
}
public static boolean  _pnlcursor_touch(int _action,float _x,float _y) throws Exception{
 //BA.debugLineNum = 578;BA.debugLine="Sub pnlCursor_Touch (Action As Int, X As Float, Y As Float) As Boolean 'Return True to consume the event";
 //BA.debugLineNum = 579;BA.debugLine="If Stopped = False Then";
if (_stopped==anywheresoftware.b4a.keywords.Common.False) { 
 //BA.debugLineNum = 580;BA.debugLine="Return";
if (true) return false;
 };
 //BA.debugLineNum = 583;BA.debugLine="Select Action";
switch (BA.switchObjectToInt(_action,mostCurrent._activity.ACTION_DOWN,mostCurrent._activity.ACTION_MOVE,mostCurrent._activity.ACTION_UP)) {
case 0:
 //BA.debugLineNum = 585;BA.debugLine="pnlDispValues.Visible = True";
mostCurrent._pnldispvalues.setVisible(anywheresoftware.b4a.keywords.Common.True);
 //BA.debugLineNum = 586;BA.debugLine="cx = X";
_cx = _x;
 //BA.debugLineNum = 587;BA.debugLine="If X >= 0 AND X <= GridW Then";
if (_x>=0 && _x<=_gridw) { 
 //BA.debugLineNum = 588;BA.debugLine="DrawCursor(X)";
_drawcursor(_x);
 //BA.debugLineNum = 589;BA.debugLine="DispValues(X)";
_dispvalues((int)(_x));
 };
 break;
case 1:
 //BA.debugLineNum = 592;BA.debugLine="If X >= 0 AND X <= GridW Then";
if (_x>=0 && _x<=_gridw) { 
 //BA.debugLineNum = 593;BA.debugLine="DrawCursor(X)";
_drawcursor(_x);
 //BA.debugLineNum = 594;BA.debugLine="DispValues(X)";
_dispvalues((int)(_x));
 };
 break;
case 2:
 //BA.debugLineNum = 597;BA.debugLine="cvsCursor.DrawLine(cx, 0, cx, GridH, Colors.Transparent, 1)";
mostCurrent._cvscursor.DrawLine(_cx,(float)(0),_cx,(float)(_gridh),anywheresoftware.b4a.keywords.Common.Colors.Transparent,(float)(1));
 //BA.debugLineNum = 598;BA.debugLine="pnlCursor.Invalidate";
mostCurrent._pnlcursor.Invalidate();
 //BA.debugLineNum = 599;BA.debugLine="pnlDispValues.Visible = False";
mostCurrent._pnldispvalues.setVisible(anywheresoftware.b4a.keywords.Common.False);
 break;
}
;
 //BA.debugLineNum = 601;BA.debugLine="Return True";
if (true) return anywheresoftware.b4a.keywords.Common.True;
 //BA.debugLineNum = 602;BA.debugLine="End Sub";
return false;
}
public static String  _process_globals() throws Exception{
 //BA.debugLineNum = 2;BA.debugLine="Sub Process_Globals";
 //BA.debugLineNum = 6;BA.debugLine="Dim Timer1 As Timer";
_timer1 = new anywheresoftware.b4a.objects.Timer();
 //BA.debugLineNum = 7;BA.debugLine="Type Curves (Name As String, Color As Int, Width As Float, Scale As Double, offset As Double, Draw As Boolean)";
;
 //BA.debugLineNum = 8;BA.debugLine="Dim CurveVal(4, 101) As Double";
_curveval = new double[(int)(4)][];
{
int d0 = _curveval.length;
int d1 = (int)(101);
for (int i0 = 0;i0 < d0;i0++) {
_curveval[i0] = new double[d1];
}
}
;
 //BA.debugLineNum = 9;BA.debugLine="Dim ScreenX0, ScreenX1, ScreenY0, ScreenY1, ScreenW, ScreenH, Border As Int";
_screenx0 = 0;
_screenx1 = 0;
_screeny0 = 0;
_screeny1 = 0;
_screenw = 0;
_screenh = 0;
_border = 0;
 //BA.debugLineNum = 10;BA.debugLine="Dim GridX0, GridX1, GridY0, GridY1, GridYm, GridW, GridH, Div As Int";
_gridx0 = 0;
_gridx1 = 0;
_gridy0 = 0;
_gridy1 = 0;
_gridym = 0;
_gridw = 0;
_gridh = 0;
_div = 0;
 //BA.debugLineNum = 11;BA.debugLine="Dim NbDivX, NbDivY As Int";
_nbdivx = 0;
_nbdivy = 0;
 //BA.debugLineNum = 12;BA.debugLine="Dim ScreenCol, GridLineCol As Int";
_screencol = 0;
_gridlinecol = 0;
 //BA.debugLineNum = 14;BA.debugLine="Dim t, dt As Double";
_t = 0;
_dt = 0;
 //BA.debugLineNum = 15;BA.debugLine="Dim dx, xx, cx As Float";
_dx = 0f;
_xx = 0f;
_cx = 0f;
 //BA.debugLineNum = 16;BA.debugLine="Dim ii As Int";
_ii = 0;
 //BA.debugLineNum = 17;BA.debugLine="Dim CurveI As Int								' curve index";
_curvei = 0;
 //BA.debugLineNum = 18;BA.debugLine="Dim Curve(4) As Curves";
_curve = new oscilo._curves[(int)(4)];
{
int d0 = _curve.length;
for (int i0 = 0;i0 < d0;i0++) {
_curve[i0] = new oscilo._curves();
}
}
;
 //BA.debugLineNum = 19;BA.debugLine="Dim CurvesI(4) As Int";
_curvesi = new int[(int)(4)];
;
 //BA.debugLineNum = 20;BA.debugLine="Dim CurvesNb As Int							: CurvesNb = 3";
_curvesnb = 0;
 //BA.debugLineNum = 20;BA.debugLine="Dim CurvesNb As Int							: CurvesNb = 3";
_curvesnb = (int)(3);
 //BA.debugLineNum = 21;BA.debugLine="Dim CurvesNbDisp As Int";
_curvesnbdisp = 0;
 //BA.debugLineNum = 22;BA.debugLine="Dim y1(4) As Float";
_y1 = new float[(int)(4)];
;
 //BA.debugLineNum = 23;BA.debugLine="Dim y2(4) As Float";
_y2 = new float[(int)(4)];
;
 //BA.debugLineNum = 24;BA.debugLine="Dim SingleShot As Boolean				: SingleShot = False";
_singleshot = false;
 //BA.debugLineNum = 24;BA.debugLine="Dim SingleShot As Boolean				: SingleShot = False";
_singleshot = anywheresoftware.b4a.keywords.Common.False;
 //BA.debugLineNum = 25;BA.debugLine="Dim Stopped As Boolean					: Stopped = True";
_stopped = false;
 //BA.debugLineNum = 25;BA.debugLine="Dim Stopped As Boolean					: Stopped = True";
_stopped = anywheresoftware.b4a.keywords.Common.True;
 //BA.debugLineNum = 26;BA.debugLine="Dim ScopeMode As String					: ScopeMode = \"ROLL\"";
_scopemode = "";
 //BA.debugLineNum = 26;BA.debugLine="Dim ScopeMode As String					: ScopeMode = \"ROLL\"";
_scopemode = "ROLL";
 //BA.debugLineNum = 27;BA.debugLine="Dim ScopeRolling As Boolean			: ScopeRolling = False";
_scoperolling = false;
 //BA.debugLineNum = 27;BA.debugLine="Dim ScopeRolling As Boolean			: ScopeRolling = False";
_scoperolling = anywheresoftware.b4a.keywords.Common.False;
 //BA.debugLineNum = 28;BA.debugLine="Dim w(4) As Double";
_w = new double[(int)(4)];
;
 //BA.debugLineNum = 29;BA.debugLine="Dim a(4) As Double";
_a = new double[(int)(4)];
;
 //BA.debugLineNum = 30;BA.debugLine="Dim TimeScale(10) As Double";
_timescale = new double[(int)(10)];
;
 //BA.debugLineNum = 31;BA.debugLine="Dim SignalScale(10) As Double";
_signalscale = new double[(int)(10)];
;
 //BA.debugLineNum = 32;BA.debugLine="Dim MSP_IDENT, MSP_STATUS,MSP_RAW_IMU  , MSP_SERVO ,MSP_MOTOR ,MSP_RC ,MSP_RAW_GPS ,MSP_COMP_GPS       ,MSP_ATTITUDE       ,MSP_ALTITUDE       ,MSP_BAT            ,MSP_RC_TUNING      ,MSP_PID            ,MSP_BOX            ,MSP_MISC           ,MSP_SET_RAW_RC     ,MSP_SET_RAW_GPS    ,MSP_SET_PID        ,MSP_SET_BOX        ,MSP_SET_RC_TUNING  ,MSP_ACC_CALIBRATION,MSP_MAG_CALIBRATION,MSP_SET_MISC       ,MSP_RESET_CONF     ,MSP_EEPROM_WRITE   ,MSP_DEBUG";
_msp_ident = "";
_msp_status = "";
_msp_raw_imu = "";
_msp_servo = "";
_msp_motor = "";
_msp_rc = "";
_msp_raw_gps = "";
_msp_comp_gps = "";
_msp_attitude = "";
_msp_altitude = "";
_msp_bat = "";
_msp_rc_tuning = "";
_msp_pid = "";
_msp_box = "";
_msp_misc = "";
_msp_set_raw_rc = "";
_msp_set_raw_gps = "";
_msp_set_pid = "";
_msp_set_box = "";
_msp_set_rc_tuning = "";
_msp_acc_calibration = "";
_msp_mag_calibration = "";
_msp_set_misc = "";
_msp_reset_conf = "";
_msp_eeprom_write = "";
_msp_debug = "";
 //BA.debugLineNum = 33;BA.debugLine="MSP_IDENT                =100";
_msp_ident = BA.NumberToString(100);
 //BA.debugLineNum = 34;BA.debugLine="MSP_STATUS               =101";
_msp_status = BA.NumberToString(101);
 //BA.debugLineNum = 35;BA.debugLine="MSP_RAW_IMU              =102";
_msp_raw_imu = BA.NumberToString(102);
 //BA.debugLineNum = 36;BA.debugLine="MSP_SERVO                =103";
_msp_servo = BA.NumberToString(103);
 //BA.debugLineNum = 37;BA.debugLine="MSP_MOTOR                =104";
_msp_motor = BA.NumberToString(104);
 //BA.debugLineNum = 38;BA.debugLine="MSP_RC                   =105";
_msp_rc = BA.NumberToString(105);
 //BA.debugLineNum = 39;BA.debugLine="MSP_RAW_GPS              =106";
_msp_raw_gps = BA.NumberToString(106);
 //BA.debugLineNum = 40;BA.debugLine="MSP_COMP_GPS             =107";
_msp_comp_gps = BA.NumberToString(107);
 //BA.debugLineNum = 41;BA.debugLine="MSP_ATTITUDE             =108";
_msp_attitude = BA.NumberToString(108);
 //BA.debugLineNum = 42;BA.debugLine="MSP_ALTITUDE             =109";
_msp_altitude = BA.NumberToString(109);
 //BA.debugLineNum = 43;BA.debugLine="MSP_BAT                  =110";
_msp_bat = BA.NumberToString(110);
 //BA.debugLineNum = 44;BA.debugLine="MSP_RC_TUNING            =111";
_msp_rc_tuning = BA.NumberToString(111);
 //BA.debugLineNum = 45;BA.debugLine="MSP_PID                  =112";
_msp_pid = BA.NumberToString(112);
 //BA.debugLineNum = 46;BA.debugLine="MSP_BOX                  =113";
_msp_box = BA.NumberToString(113);
 //BA.debugLineNum = 47;BA.debugLine="MSP_MISC                 =114";
_msp_misc = BA.NumberToString(114);
 //BA.debugLineNum = 48;BA.debugLine="MSP_SET_RAW_RC           =200";
_msp_set_raw_rc = BA.NumberToString(200);
 //BA.debugLineNum = 49;BA.debugLine="MSP_SET_RAW_GPS          =201";
_msp_set_raw_gps = BA.NumberToString(201);
 //BA.debugLineNum = 50;BA.debugLine="MSP_SET_PID              =202";
_msp_set_pid = BA.NumberToString(202);
 //BA.debugLineNum = 51;BA.debugLine="MSP_SET_BOX              =203";
_msp_set_box = BA.NumberToString(203);
 //BA.debugLineNum = 52;BA.debugLine="MSP_SET_RC_TUNING        =204";
_msp_set_rc_tuning = BA.NumberToString(204);
 //BA.debugLineNum = 53;BA.debugLine="MSP_ACC_CALIBRATION      =205";
_msp_acc_calibration = BA.NumberToString(205);
 //BA.debugLineNum = 54;BA.debugLine="MSP_MAG_CALIBRATION      =206";
_msp_mag_calibration = BA.NumberToString(206);
 //BA.debugLineNum = 55;BA.debugLine="MSP_SET_MISC             =207";
_msp_set_misc = BA.NumberToString(207);
 //BA.debugLineNum = 56;BA.debugLine="MSP_RESET_CONF           =208";
_msp_reset_conf = BA.NumberToString(208);
 //BA.debugLineNum = 57;BA.debugLine="MSP_EEPROM_WRITE         =250";
_msp_eeprom_write = BA.NumberToString(250);
 //BA.debugLineNum = 58;BA.debugLine="MSP_DEBUG                =254";
_msp_debug = BA.NumberToString(254);
 //BA.debugLineNum = 59;BA.debugLine="Dim stateMSP,offset,dataSize,indTX As Int";
_statemsp = 0;
_offset = 0;
_datasize = 0;
_indtx = 0;
 //BA.debugLineNum = 60;BA.debugLine="checksum=0";
_checksum = (byte)(0);
 //BA.debugLineNum = 61;BA.debugLine="stateMSP=0";
_statemsp = (int)(0);
 //BA.debugLineNum = 62;BA.debugLine="offset=0";
_offset = (int)(0);
 //BA.debugLineNum = 63;BA.debugLine="dataSize=0";
_datasize = (int)(0);
 //BA.debugLineNum = 64;BA.debugLine="indTX=0";
_indtx = (int)(0);
 //BA.debugLineNum = 65;BA.debugLine="Dim checksum As Byte";
_checksum = 0;
 //BA.debugLineNum = 66;BA.debugLine="End Sub";
return "";
}
public static int  _read16(int _b,int _c) throws Exception{
 //BA.debugLineNum = 313;BA.debugLine="Sub read16(b As Int, c As Int) As Int";
 //BA.debugLineNum = 314;BA.debugLine="Return Bit.And(b,0xFF) + Bit.ShiftLeft(Bit.And(c,0xFF),8)";
if (true) return (int)(anywheresoftware.b4a.keywords.Common.Bit.And(_b,(int)(0xff))+anywheresoftware.b4a.keywords.Common.Bit.ShiftLeft(anywheresoftware.b4a.keywords.Common.Bit.And(_c,(int)(0xff)),(int)(8)));
 //BA.debugLineNum = 315;BA.debugLine="End Sub";
return 0;
}
public static int  _read32(int _b,int _c,int _d,int _e) throws Exception{
 //BA.debugLineNum = 316;BA.debugLine="Sub read32(b As Int, c As Int,d As Int, e As Int) As Int";
 //BA.debugLineNum = 317;BA.debugLine="Return Bit.And(read16(b,c),0xFF) + Bit.ShiftLeft(Bit.And(read16(d,e),0xFF),16)";
if (true) return (int)(anywheresoftware.b4a.keywords.Common.Bit.And(_read16(_b,_c),(int)(0xff))+anywheresoftware.b4a.keywords.Common.Bit.ShiftLeft(anywheresoftware.b4a.keywords.Common.Bit.And(_read16(_d,_e),(int)(0xff)),(int)(16)));
 //BA.debugLineNum = 318;BA.debugLine="End Sub";
return 0;
}
public static int  _read8(int _b) throws Exception{
 //BA.debugLineNum = 320;BA.debugLine="Sub read8(b As Int) As Int";
 //BA.debugLineNum = 321;BA.debugLine="Return Bit.And(b,0xFF)";
if (true) return anywheresoftware.b4a.keywords.Common.Bit.And(_b,(int)(0xff));
 //BA.debugLineNum = 322;BA.debugLine="End Sub";
return 0;
}
public static String  _spnscale_itemclick(int _position,Object _value) throws Exception{
anywheresoftware.b4a.objects.SpinnerWrapper _spn = null;
 //BA.debugLineNum = 272;BA.debugLine="Sub spnScale_ItemClick (Position As Int, Value As Object)";
 //BA.debugLineNum = 273;BA.debugLine="Dim spn As Spinner";
_spn = new anywheresoftware.b4a.objects.SpinnerWrapper();
 //BA.debugLineNum = 274;BA.debugLine="spn = Sender";
_spn.setObject((anywheresoftware.b4a.objects.SpinnerWrapper.B4ASpinner)(anywheresoftware.b4a.keywords.Common.Sender(mostCurrent.activityBA)));
 //BA.debugLineNum = 275;BA.debugLine="Curve(spn.Tag).Scale = Div / Value";
_curve[(int)(BA.ObjectToNumber(_spn.getTag()))].Scale = _div/(double)(double)(BA.ObjectToNumber(_value));
 //BA.debugLineNum = 276;BA.debugLine="End Sub";
return "";
}
public static String  _timer1_tick() throws Exception{
int _i = 0;
int _j = 0;
 //BA.debugLineNum = 323;BA.debugLine="Sub Timer1_Tick";
 //BA.debugLineNum = 324;BA.debugLine="Dim i, j As Int";
_i = 0;
_j = 0;
 //BA.debugLineNum = 326;BA.debugLine="t = t + dt";
_t = _t+_dt;
 //BA.debugLineNum = 327;BA.debugLine="xx = xx + dx";
_xx = (float)(_xx+_dx);
 //BA.debugLineNum = 328;BA.debugLine="ii = ii + 1";
_ii = (int)(_ii+1);
 //BA.debugLineNum = 329;BA.debugLine="If ii > 100 Then";
if (_ii>100) { 
 //BA.debugLineNum = 330;BA.debugLine="If SingleShot = True Then";
if (_singleshot==anywheresoftware.b4a.keywords.Common.True) { 
 //BA.debugLineNum = 331;BA.debugLine="Timer1.Enabled = False";
_timer1.setEnabled(anywheresoftware.b4a.keywords.Common.False);
 //BA.debugLineNum = 332;BA.debugLine="SingleShot = False";
_singleshot = anywheresoftware.b4a.keywords.Common.False;
 //BA.debugLineNum = 333;BA.debugLine="Stopped = True";
_stopped = anywheresoftware.b4a.keywords.Common.True;
 //BA.debugLineNum = 334;BA.debugLine="Return";
if (true) return "";
 }else {
 //BA.debugLineNum = 336;BA.debugLine="Select ScopeMode";
switch (BA.switchObjectToInt(_scopemode,"MEM","SCOPE","ROLL")) {
case 0:
 //BA.debugLineNum = 338;BA.debugLine="xx = 0";
_xx = (float)(0);
 //BA.debugLineNum = 339;BA.debugLine="ii = 0";
_ii = (int)(0);
 //BA.debugLineNum = 340;BA.debugLine="GetValues";
_getvalues();
 //BA.debugLineNum = 341;BA.debugLine="DrawCurves";
_drawcurves();
 break;
case 1:
 //BA.debugLineNum = 343;BA.debugLine="EraseCurves";
_erasecurves();
 //BA.debugLineNum = 344;BA.debugLine="xx = 0";
_xx = (float)(0);
 //BA.debugLineNum = 345;BA.debugLine="ii = 0";
_ii = (int)(0);
 //BA.debugLineNum = 346;BA.debugLine="GetValues";
_getvalues();
 //BA.debugLineNum = 347;BA.debugLine="DrawCurves";
_drawcurves();
 break;
case 2:
 //BA.debugLineNum = 349;BA.debugLine="ii = 100";
_ii = (int)(100);
 //BA.debugLineNum = 350;BA.debugLine="xx = 100 * dx";
_xx = (float)(100*_dx);
 //BA.debugLineNum = 351;BA.debugLine="For i = 0 To 3";
{
final double step293 = 1;
final double limit293 = (int)(3);
for (_i = (int)(0); (step293 > 0 && _i <= limit293) || (step293 < 0 && _i >= limit293); _i += step293) {
 //BA.debugLineNum = 352;BA.debugLine="For j = 0 To 99";
{
final double step294 = 1;
final double limit294 = (int)(99);
for (_j = (int)(0); (step294 > 0 && _j <= limit294) || (step294 < 0 && _j >= limit294); _j += step294) {
 //BA.debugLineNum = 353;BA.debugLine="CurveVal(i, j) = CurveVal(i, j + 1)";
_curveval[_i][_j] = _curveval[_i][(int)(_j+1)];
 }
};
 }
};
 //BA.debugLineNum = 356;BA.debugLine="ScopeRolling = True";
_scoperolling = anywheresoftware.b4a.keywords.Common.True;
 //BA.debugLineNum = 357;BA.debugLine="GetValues";
_getvalues();
 //BA.debugLineNum = 358;BA.debugLine="DrawCurves";
_drawcurves();
 break;
}
;
 //BA.debugLineNum = 360;BA.debugLine="Return";
if (true) return "";
 };
 };
 //BA.debugLineNum = 363;BA.debugLine="GetValues";
_getvalues();
 //BA.debugLineNum = 364;BA.debugLine="DrawCurves";
_drawcurves();
 //BA.debugLineNum = 365;BA.debugLine="End Sub";
return "";
}
}
